Code Monkey home page Code Monkey logo

proc-isolation's Introduction

  • This repository has been archived.
  • No longer maintained.
  • All versions have been removed from https://rubygems.org to free up valuable namespace for other developers.

proc-isolation

An evil tool, this gem expose hidden feature around Proc#isolate in CRuby.
Do not use in your production code, stop to use just only fun in your sandbox. :)


Build Status

Usage

Require Ruby 3.0 or later

Overview

require 'proc/isolation'

prc = ->{ 42 }
prc.isolate #=> New isolated Proc instance will be returned

prc.isolate! #=> The Proc instance will be isolated

local_variable = 42
-> { local_variable }.isolate #=> can not isolate a Proc because it accesses outer variables (local_variable). (ArgumentError)

Links

proc-isolation's People

Contributors

dependabot[bot] avatar kachick avatar

Watchers

 avatar  avatar  avatar

proc-isolation's Issues

Implement `Proc#isolated?`

typedef struct rb_proc_t;

#define GetCoreDataFromValue(obj, type, ptr) ((ptr) = CoreDataFromValue((obj), type))

#define GetProcPtr(obj, ptr) \
  GetCoreDataFromValue((obj), rb_proc_t, (ptr))

static typedef struct {
    // const struct rb_block VALUE;
    unsigned int is_from_method: 1;	/* bool */
    unsigned int is_lambda: 1;		/* bool */
    unsigned int is_isolated: 1;        /* bool */
} rb_proc_t;


VALUE
rb_proc_lambda_p(VALUE procval)
{
    rb_proc_t *proc;
    GetProcPtr(procval, proc);

    return proc->is_lambda ? Qtrue : Qfalse;
}

VALUE
rb_proc_isolated_p(VALUE procval)
{
    rb_proc_t *proc;
    GetProcPtr(procval, proc);

    return proc->is_isolated ? Qtrue : Qfalse;
}


        // proc->is_isolated = TRUE;

void
Init_proc_isolation(void)
{
  rb_define_method(rb_cProc, "isolated?", rb_proc_isolated_p, 0);
}

This is my image, but can't work ๐Ÿค”

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.