[#383997] CORE - Alternative Variable Substitution — Ilias Lazaridis <ilias@...>
ruby 1.9
On 1 =C9=EF=FD=ED, 12:12, Peter Hickman <peterhickman...@googlemail.com>
On 1 =C9=EF=FD=ED, 16:22, Robert Klemme <shortcut...@googlemail.com> wrote:
On Thu, 2 Jun 2011 13:25:25 +0900, Ilias Lazaridis wrote:
[#384020] instance variable in pseudo-global scope — Chad Perrin <code@...>
As I understand things:
On Wed, Jun 1, 2011 at 6:01 PM, Chad Perrin <code@apotheon.net> wrote:
[#384029] minitest 2.2.2 Released — Ryan Davis <ryand-ruby@...>
minitest version 2.2.2 has been released!
[#384051] CORE - Replace "if __FILE__ == $0" with "executed?" — Ilias Lazaridis <ilias@...>
The construct to detect execution of the file (in order to launch main
On Thu, 2 Jun 2011 22:30:27 +0900, Ilias Lazaridis wrote:
On Thu, Jun 02, 2011 at 10:51:46PM +0900, Peter Zotov wrote:
[#384072] Behaviour of different Proc types — Josh Cheek <josh.cheek@...>
I realized that I just can't ever remember the different proc types
[#384085] Best way to replace hash keys — Alex Allmont <Alex.Allmont@...>
What is the most optimal and neatest way to replace keys in a hash given a =
[#384104] CORE - Altering Behaviour of "each do" (default param "item") — Ilias Lazaridis <ilias@...>
1.9
Probably not without changing Ruby itself.
Actually it would be possible, although very ugly.
On Sat, Jun 4, 2011 at 6:50 AM, Ilias Lazaridis <ilias@lazaridis.com> wrote:
On Sat, Jun 04, 2011 at 11:50:00PM +0900, James Gray wrote:
On 5 =CE=99=CE=BF=CF=8D=CE=BD, 17:19, Matthias W=C3=A4chter <matth...@waech=
Hi,
Ilias Lazaridis wrote:
2011/6/7 J=C3=B6rg W Mittag <JoergWMittag+Ruby@googlemail.com>
On 6 =C9=EF=FD=ED, 01:11, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:
On Monday, June 06, 2011 03:35:30 AM Ilias Lazaridis wrote:
On 06.06.2011 16:57, David Masover wrote:
On 6 =C9=EF=FD=ED, 01:11, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:
Hi,
On 6 =CE=99=CE=BF=CF=8D=CE=BD, 12:24, Yukihiro Matsumoto <m...@ruby-lang.or=
On 8 =CE=99=CE=BF=CF=8D=CE=BD, 08:06, David Masover <ni...@slaphack.com> wr=
On Wed, Jun 8, 2011 at 11:50 AM, Ilias Lazaridis <ilias@lazaridis.com> wrot=
[#384208] Ruby 1.9 Time parse question — Paul <tester.paul@...>
Hi there!
[#384219] how to repackage a ruby gem. — William Liu <william.weih@...>
Hi All,
[#384228] a little challenge - reproduce this error — Intransition <transfire@...>
Want to see a really amazing error I got this week? Okay... but to
throw NameError.new("uninitialized constant X::Foo::X")
This is a pretty trivial error to generate. Just reference the
On Wed, Jun 8, 2011 at 6:43 AM, Intransition <transfire@gmail.com> wrote:
On Jun 8, 2011, at 10:56 AM, Christopher Dicely wrote:
On Jun 8, 10:56=A0am, Christopher Dicely <cmdic...@gmail.com> wrote:
On Wed, Jun 8, 2011 at 8:27 AM, Intransition <transfire@gmail.com> wrote:
> I realize now maybe how I should have phrased this as a challenge
On Jun 9, 1:22=A0pm, John Feminella <jo...@bitsbuilder.com> wrote:
On Fri, Jun 10, 2011 at 12:08 PM, Intransition <transfire@gmail.com> wrote:
[#384262] Where is the #hash method defined? — Iñaki Baz Castillo <ibc@...>
Hi, any object in Ruby has the method #hash which returns an integer
> I cannot find which class or module #hash method belongs to. I
[#384273] Anyone compiled VIM 7.3 with 1.9.2 support? — Ned <rails.nerd@...>
Hi
[#384279] CORE - Literal Instantiation breaks Object Model — Ilias Lazaridis <ilias@...>
class String
[#384280] BARRIER - require "rubygems" — Ilias Lazaridis <ilias@...>
ruby 1.9.2p180 Windows 7
On 11 =C9=EF=FD=ED, 20:30, Phillip Gawlowski <cmdjackr...@googlemail.com>
[#384283] Classic Computer Science Books — Stu <stu@...>
I wanted to start a thread discussion on classic computer science
On Thu, Jun 9, 2011 at 5:18 PM, Stu <stu@rubyprogrammer.net> wrote:
On Fri, Jun 10, 2011 at 09:22:58AM +0900, Josh Cheek wrote:
Thank you for the responses. I look forward to reading others.
> queue to read Meyers C++ books and Crockford's Javascript: The Good
Hello Anurag
Hey Stu,
Wow, those are a lot of books, as a beginner programmer, I don't have
There is a classic series online called "How to Think Like a Computer Scien=
On Thu, Jun 16, 2011 at 10:26 PM, Stu <stu@rubyprogrammer.net> wrote:
On 10.06.2011 00:18, Stu wrote:
The Design and Construction of Compilers, Robin Hunter, John Wiley &
[#384322] PSA: Ilias is Crazy — Ryan Davis <ryand-ruby@...>
I guess I have to post this periodically since our population is growing =
On 6/10/2011 12:41 PM, Ryan Davis wrote:
Since this has escalated to giving the guy a thread with his name in
[#384363] RFC - One word alias for require_relative — Ilias Lazaridis <ilias@...>
This is a simple Request for Comments.
On 16 =C9=EF=FD=ED, 19:45, "Matthew K. Williams" <m...@harpstar.com> wrote:
On Sat, Jun 11, 2011 at 9:12 PM, Intransition <transfire@gmail.com> wrote:
On Sat, Jun 11, 2011 at 11:08 PM, Intransition <transfire@gmail.com> wrote:
Back in the blissful days before I understood the `$LOAD_PATH` or the
On 15 =C9=EF=FD=ED, 22:26, Florian Gilcher <f...@andersground.net> wrote:
On 15 =C9=EF=FD=ED, 22:58, Michael Edgar <ad...@carboni.ca> wrote:
On 15 =C9=EF=FD=ED, 23:22, Michael Edgar <ad...@carboni.ca> wrote:
On 11 =C9=EF=FD=ED, 20:35, Ilias Lazaridis <il...@lazaridis.com> wrote:
On 16 =C9=EF=FD=ED, 17:29, Matt Harrison <iwasinnamuk...@genestate.com> wro=
On 16/06/2011 16:10, Ilias Lazaridis wrote:
On 16 =C9=EF=FD=ED, 20:26, Matt Harrison <iwasinnamuk...@genestate.com> wro=
On 16 =CE=99=CE=BF=CF=8D=CE=BD, 21:24, Jason Roelofs <jameskil...@gmail.com=
involve
On 16 =CE=99=CE=BF=CF=8D=CE=BD, 23:45, Adam Prescott <a...@aprescott.com> w=
On 11 =C9=EF=FD=ED, 20:35, Ilias Lazaridis <il...@lazaridis.com> wrote:
On 17 =C9=EF=FD=ED, 21:17, Gary Wright <gwtm...@mac.com> wrote:
2011/6/17 Ilias Lazaridis <ilias@lazaridis.com>:
On Mon, Jun 20, 2011 at 2:54 PM, Christopher Dicely <cmdicely@gmail.com> wrote:
On Monday, June 20, 2011 09:17:51 AM Adam Prescott wrote:
On 17 =C9=EF=FD=ED, 23:15, Phillip Gawlowski <cmdjackr...@googlemail.com>
2011/6/17 Ilias Lazaridis <ilias@lazaridis.com>
2011/6/17 Salk Pugh-Pitt <salk.pughpitt@gmail.com>
On Fri, Jun 17, 2011 at 4:32 PM, A. Stroh Turph <astroh.turph@gmail.com>wrote:
On Fri, Jun 17, 2011 at 4:37 PM, Salk Pugh-Pitt <salk.pughpitt@gmail.com>wrote:
On 11 =C9=EF=FD=ED, 20:35, Ilias Lazaridis <il...@lazaridis.com> wrote:
Hi,
On 18 =C9=EF=FD=ED, 02:30, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:
On 19 =CE=99=CE=BF=CF=8D=CE=BD, 19:44, David Masover <ni...@slaphack.com> w=
On Sunday, June 19, 2011 12:20:28 PM Ilias Lazaridis wrote:
On 21 =CE=99=CE=BF=CF=8D=CE=BD, 21:55, I=C3=B1aki Baz Castillo <i...@aliax.=
[#384375] sequel question: Where's SQLite? — Chad Perrin <code@...>
So . . . I need to get the Sequel gem working with SQLite on a Debian
On Sat, Jun 11, 2011 at 2:30 PM, Chad Perrin <code@apotheon.net> wrote:
On Sat, Jun 11, 2011 at 2:55 PM, Mike Moore <blowmage@gmail.com> wrote:
On Sun, Jun 12, 2011 at 05:57:42AM +0900, Mike Moore wrote:
[#384432] commit message conventions — Intransition <transfire@...>
When I write commit messages I add a "team" prefix to the message,
I greatly dislike that style, to be frank. My commit messages usually
On Mon, Jun 13, 2011 at 7:58 AM, John Feminella <johnf@bitsbuilder.com> wro=
On Jun 13, 9:13=A0am, brab...@gmail.com wrote:
On Jun 13, 2011, at 9:55 AM, Intransition <transfire@gmail.com> wrote:
Agreed. Reference the ticket, which can hold all the data about what
[#384444] Hi rubies — medarkness arkness <rotakinrof@...>
[#384453] Regexp.match(line) question — m b <snert@...>
[#384467] A way to find out when a constant gets defined? — Josh Cheek <josh.cheek@...>
Hi, I'd like to be able to find out when a constant gets defined. I think I
> but the Bundler team
Okay, I think I found the ultimate source of the problem was that RVM said
On Tue, Jun 14, 2011 at 2:11 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
[#384473] ruby-oci8 2.0.6 — Kubo Takehiro <kubo@...>
Ruby-oci8 2.0.6 is released. This is the Oracle module using OCI8 API.
[#384490] Messages to Ruby List/Forum/etc. not arriving equally? — Markus Fischer <markus@...>
Hi,
On Wed, Jun 15, 2011 at 2:20 AM, Markus Fischer <markus@fischer.name> wrote:
Hi,
On Wed, Jun 15, 2011 at 4:28 AM, Markus Fischer <markus@fischer.name> wrote:
http://www.ruby-forum.com/topic/2440238#1018634 arrived in the mailing list
[#384494] Plugin best practices — Intransition <transfire@...>
If your making a plugin/extension for another project, do you create a
[#384500] CORE - Inconsistent Handling of Uninitialized Variables — Ilias Lazaridis <ilias@...>
puts "\n== Testin in MAIN Context =="
On 15 =C9=EF=FD=ED, 21:05, Michael Edgar <ad...@carboni.ca> wrote:
On Jun 19, 2011, at 6:01 PM, Gary Wright wrote:
[#384521] queues? inotify? anything else? — Matt Harrison <iwasinnamuknow@...>
I don't even really know how to describe this problem. I know what I
[#384532] Kernel#autoload vs require_relative — Piotr Szotkowski <chastell@...>
I understand that for require to work relative to the given __FILE__=E2=80=
Ryan Davis:
On Thursday, June 16, 2011 11:50:57 AM Piotr Szotkowski wrote:
[#384579] win32-service gem — Daniel Stephens <danny.a.stephens@...>
Hey all, has anyone been able to use win32-service-0.7.0.gem. when I try to
[#384617] get execution name of program — Chad Perrin <code@...>
Either $0 or __FILE__ will return a filename to give context for how a
On Jun 17, 2011, at 1:49 PM, Chad Perrin wrote:
On Sat, Jun 18, 2011 at 03:03:50AM +0900, Michael Edgar wrote:
On Jun 17, 2011, at 2:16 PM, Chad Perrin wrote:
On Fri, Jun 17, 2011 at 11:16 AM, Chad Perrin <code@apotheon.net> wrote:
[#384634] default config file location — Chad Perrin <code@...>
Is there a "better" way to specify a default config file location than
Chad Perrin:
On Sat, 18 Jun 2011, Chad Perrin wrote:
On 6/17/2011 14:45, Matthew K. Williams wrote:
[#384648] celluloid 0.0.3: a concurrent object framework for Ruby — Tony Arcieri <tony.arcieri@...>
Celluloid is a concurrent object framework for Ruby inspired by Erlang
On Friday, June 17, 2011 03:21:48 PM Tony Arcieri wrote:
On Fri, Jun 17, 2011 at 4:25 PM, David Masover <ninja@slaphack.com> wrote:
On Friday, June 17, 2011 05:54:35 PM Tony Arcieri wrote:
On Fri, Jun 17, 2011 at 6:25 PM, David Masover <ninja@slaphack.com> wrote:
[#384650] Threadsafing a mixin module without using self.new or initialize. — Mike Bethany <mikbe.tk@...>
Threadsafing a mixin module without using self.new or initialize.
[#384687] how would you set dynamically determined dependencies with or without bundler? — Jarmo Pertman <jarmo.p@...>
Hi!
[#384697] test scope issue — Chad Perrin <code@...>
My tests are broken. I generally suck at writing tests, so please bear
[#384742] What about Object#to_ruby ? — Bernard Lambeau <blambeau@...>
Hi!
I believe pry has this kind of thing: https://github.com/banister/pry
On Mon, Jun 20, 2011 at 7:40 AM, Bernard Lambeau <blambeau@gmail.com> wrote:
[#384763] MIDASWAD - Matz is Dumb and so We are Dumb — Ilias Lazaridis <ilias@...>
(public draft)
Before anyone engages this nonsense . . .
On 20 Jun 2011 20:32, "Chad Perrin" <code@apotheon.net> wrote:
Five posts in on this thread, and four of them are the self appointed
On Mon, Jun 20, 2011 at 11:08 PM, Sam Duncan <sduncan@wetafx.co.nz> wrote:
On Mon, Jun 20, 2011 at 23:08, Sam Duncan <sduncan@wetafx.co.nz> wrote:
A quick, lazy response, because I shouldn't feed trolls anyway, and I simply
On Mon, Jun 20, 2011 at 23:52, David Masover <ninja@slaphack.com> wrote:
On Tue, Jun 21, 2011 at 11:06 AM, Nikolai Weibull <now@bitwi.se> wrote:
On Tue, Jun 21, 2011 at 13:37, Adam Prescott <adam@aprescott.com> wrote:
On Tue, Jun 21, 2011 at 1:39 PM, Nikolai Weibull <now@bitwi.se> wrote:
On Tue, Jun 21, 2011 at 14:51, Adam Prescott <adam@aprescott.com> wrote:
[#384784] REWORK - Task: Unify behaviour of by-literal-instantiated Objects — Ilias Lazaridis <ilias@...>
(Note: This task is part of the RUBY REWORK, which has (among other
[#384800] How to order a hash based on its keys? — Iñaki Baz Castillo <ibc@...>
Hi, I want to order a hash using itds keys:
On Tue, Jun 21, 2011 at 4:34 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
2011/6/21 Robert Klemme <shortcutter@googlemail.com>:
2011/6/21 I=C3=B1aki Baz Castillo <ibc@aliax.net>:
On Tue, Jun 21, 2011 at 6:34 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
2011/6/22 Robert Klemme <shortcutter@googlemail.com>:
On Wed, Jun 22, 2011 at 11:50 AM, I=F1aki Baz Castillo <ibc@aliax.net> wrot=
2011/6/22 Robert Klemme <shortcutter@googlemail.com>:
On Wed, Jun 22, 2011 at 3:47 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
2011/6/22 Robert Klemme <shortcutter@googlemail.com>:
On Wed, Jun 22, 2011 at 4:19 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
2011/6/22 Robert Klemme <shortcutter@googlemail.com>:
On Thu, Jun 23, 2011 at 12:11 AM, I=F1aki Baz Castillo <ibc@aliax.net> wrot=
2011/6/23 Robert Klemme <shortcutter@googlemail.com>:
On Thu, Jun 23, 2011 at 6:42 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
On Wed, Jun 22, 2011 at 11:50 AM, I=F1aki Baz Castillo <ibc@aliax.net> wrot=
[#384801] Once click, one (OO) life... — DavCori80 <davcori80@...>
Hi everyone,
[#384819] Gateway Shutting Down — James Gray <james@...>
Rubyists:
On Wed, Jun 22, 2011 at 1:47 AM, James Gray <james@graysoftinc.com> wrote:
On Wed, Jun 22, 2011 at 12:18 AM, Martin DeMello
[#384863] vlad 2.2.1 Released — Ryan Davis <ryand-ruby@...>
vlad version 2.2.1 has been released!
2011/6/23 Ryan Davis <ryand-ruby@zenspider.com>:
[#384864] Ruby embed called from a pthread — Luiz Angelo Daros de Luca <luizluca@...>
Hello guys,
[#384873] Explicitly setting compiler to C++ in extconf.rb... — "Darryl L. Pierce" <mcpierce@...>
I'm trying to setup a Ruby gem that bundles the Swig-generated bindings
Darryl L. Pierce escreveu isso a=ED:
On Jun 23, 2011, at 7:30 PM, Antonio Terceiro wrote:
On 06/23/2011 07:39 PM, Michael Edgar wrote:
[#384891] Honoring #to_ary and such — Intransition <transfire@...>
Well, for about the first time I am writing a library that has to be
On Fri, Jun 24, 2011 at 3:38 PM, Intransition <transfire@gmail.com> wrote:
[#384901] Symbol#=== — Intransition <transfire@...>
As:
On Sat, Jun 25, 2011 at 7:57 AM, Intransition <transfire@gmail.com> wrote:
On Sat, Jun 25, 2011 at 9:15 PM, Intransition <transfire@gmail.com> wrote:
[#384907] SPDX (and the glazing of ones eyes) — Intransition <transfire@...>
Never ceases to amaze me how complicated "enterprisey" peoples can
On Sat, Jun 25, 2011 at 10:00 AM, Intransition <transfire@gmail.com> wrote:
On Jun 25, 11:11=A0am, Josh Cheek <josh.ch...@gmail.com> wrote:
On Sun, Jun 26, 2011 at 04:41:06AM +0900, Intransition wrote:
On Sat, Jun 25, 2011 at 5:00 PM, Intransition <transfire@gmail.com> wrote:
<snip>
On Jun 25, 11:54=A0am, Phillip Gawlowski <cmdjackr...@googlemail.com>
On Sat, Jun 25, 2011 at 9:36 PM, Intransition <transfire@gmail.com> wrote:
[#384927] Single Responsibility Question — Mike Bethany <mikbe.tk@...>
I'm trying to figure out who's responsible for a resource.
On Sun, Jun 26, 2011 at 2:22 AM, Mike Bethany <mikbe.tk@gmail.com> wrote:
Thanks Robert, you always have excellent feedback.
[#384931] Rubicle, the unofficial Ruby mascot, released — info@...
Hello! We are rubicle.net administrators. We have released Rubicle, the UNOFFICIAL
So this is Ruby-tan? (ala http://en.wikipedia.org/wiki/OS-tan)
On Sun, Jun 26, 2011 at 2:26 PM, Tony Arcieri <tony.arcieri@gmail.com>wrote:
[#384945] unicorn 4.0.0 - Rack HTTP server for fast clients and Unix — Eric Wong <normalperson@...>
Unicorn is an HTTP server for Rack applications designed to only serve
[#384950] Understanding Threading... — "Darryl L. Pierce" <mcpierce@...>
I'm working on a use case where I need to spawn a thread that handles a
[#384976] clock-scheduled operations — Chad Perrin <code@...>
Obviously, scheduling something to happen every foo seconds is easy.
[#384982] here docs: WTF am i doing wrong??? — serialhex <serialhex@...>
ok, so i'm trying to create a here doc for a little program i'm writing and
[#384996] A movie Renamer — Mayank Kohaley <mayank.kohaley@...>
Hello Guys,
Please don't steal movies.
On Thu, Jun 30, 2011 at 06:17:55AM +0900, Sam Duncan wrote:
*sigh*
Really didn't want to get into this, especially since it seems like everyone
[#385002] Specifying non-standard include/lib directories on gem install... — "Darryl L. Pierce" <mcpierce@...>
Is it possible to specific non-standard directories when installing a
[#385019] A File Renamer — Mayank Kohaley <mayank.kohaley@...>
I guess this thread has spawned another issue. Let me close this and say I
On Thu, Jun 30, 2011 at 1:48 AM, Mayank Kohaley
> Is there a pattern to the file names you are working with? The key is
On Thu, Jun 30, 2011 at 10:55 AM, Johnny Morrice <spoon@killersmurf.com>wrote:
You should be aware that meta data can't be trusted. Not only do people not
On Thu, Jun 30, 2011 at 3:37 PM, Mike Bethany <mikbe.tk@gmail.com> wrote:
Re: [ANN] celluloid 0.0.3: a concurrent object framework for Ruby
On Friday, June 17, 2011 05:54:35 PM Tony Arcieri wrote:
> On Fri, Jun 17, 2011 at 4:25 PM, David Masover <ninja@slaphack.com> wrote:
> > Speaking of semantics, my biggest problems were:
> > - Is there a way to handle exceptions in a Ruby-esque way?
> >
> > It looks like I have to explicitly trap actor exceptions. But this is a
> > place
> > I have to be aware that this is an actor and not just a Ruby object.
>
> When making synchronous calls, exceptions which occur in the context of the
> receiver are automatically reraised in the caller just like any other Ruby
> object, regardless of if you're using any actor-specific features like
> linking or trapping exits. It will also crash the receiver.
That makes sense.
But when making asynchronous calls:
> Your parallel map is a perfect example of what I'd actually want here: If
> an
>
> > exception is raised, re-raise that exception when I try to call methods
> > on the
> > actor, rather than DeadActorException. Is there a reason not to do that?
>
> I think reraising the original exception in the caller context gives the
> caller appropriate context to bail out of whatever they're doing and avoid
> making subsequent calls at all. Other threads may be trying to make calls,
> and if an exception entirely unrelated to the calls they're making is
> raised because the actor is dead, I think that'd be rather confusing.
That makes a lot of sense.
Still, I shouldn't have to create an entire new actor, link it to your actor,
and have it trap errors in order to find the actual exception I caused which
lead to the actor's death. Maybe it's appropriate for bang methods to return
some object which can be used to retrieve an exception?
> - How do you handle cycles?
>
>
> I don't, but they can be detected if you don't mind a bit of a performance
> penalty. For that I need to track chains of synchronous calls and detect if
> the receiver of a given method exists earlier in the call chain. If so,
> Celluloid can raise an exception in the caller context indicating that a
> deadlock would occur. This is a bit of a glaring deficiency right now.
That's what I was trying to do, except I wasn't planning to deadlock. I was
planning to allow the call... somehow. Basically, if you had any sort of
pattern where two objects call methods on each other, it should work the way
it does synchronously.
I think this makes sense, semantically. After all, if an actor calls a method
on itself, we don't get any sort of deadlock. If an actor calls a method on
another object running in the same thread, which then calls a method on the
actor, at least with my implementation, this also doesn't deadlock -- and in
yours, if I pass 'self' around, we get the same result. Why should it be
different if I call a method on another _actor_ which then calls a method on
me?
Still, it's tricky to come up with an efficient way to do this, and I never
managed to get anything to work, no matter how inefficient.
> First, 'self' wouldn't be an actor reference, it'd be the object itself,
>
> > right?
>
> Yes. I provide Celluloid.current_actor to use in lieu of self. This feels a
> bit ugly, but I don't know of any way to redefine self (nor do I think
> that'd be a particularly good idea either)
So, there is a way, but you probably won't like it...
One experiment I did here was:
- Grab all methods, stuff them in a hash, and undef them.
- When a method is called, intercept it like a proxy, and do whatever I need
to do to get it to the right thread.
- To actually call the method, grab the method object, bind it to self, and
apply.
It's not really redefining self, but it accomplishes what's needed here.
However, I suspect it breaks all kinds of inheritance, unless I also absorb
that kind of functionality -- that is, whenever something inherits from this
class, give it a clone of the hash to start with.
One advantage to this approach is that I could very easily allow some methods
to require the actor thread, and some methods to run in the calling thread --
by default, they run in the actor thread. The obvious application is when a
method really doesn't need to involve the actor:
class Sheen
include Suit
# define a new threadsafe method
threadsafe :status do
:winning
end
end
But maybe you want to anyway:
class Sheen
include Suit
attr_reader :status, :sober
def initialize
@status = :winning
@sober = true
end
def fall_off_wagon!
@status = :WINNING
@sober = false
end
def is_off_wagon?
!sober && status == :WINNING
end
threadsafe :hello do
if is_off_wagon?
puts 'WINNING!!!'
else
puts 'Hi.'
end
end
end
It makes sense that fall_off_wagon! and is_off_wagon? should run on the actor
thread. It makes sense that the 'hello' method doesn't really need to run on
the actor thread, and maybe it's a performance improvement that the Sheen
thread doesn't actually have to talk, or ever wait for output, etc. I'm really
reaching here, because I don't actually have a real application for this, but
I don't think it's entirely unreasonable -- kind of like the Java
'synchronized' keyword, except message-passing behavior is the default.
But notice that the 'threadsafe' call doesn't have to call 'self' at all. In
fact, that syntax is actually syntactic sugar for:
def hello
...
end
threadsafe :hello
I'm still just writing normal methods, but every method call, whether it's to
'self' or not, is still going through the same logic to determine whether or
not it needs to run on the Sheen thread.
I was much more interested in getting the semantics right, to show that it can
be done, rather than making it performant and immediately useful. Like you, I
wanted to use this to sort of prototype those semantics, with the hope that
they would get into something like Reia eventually. (I started this before I
heard of Reia, and probably before Reia was in any way practical, so I wasn't
deliberately reinventing the wheel.)
> > I really don't like the registry -- one flat namespace of actors? Ew. But
> > I'm not really sure how to solve this -- some sort of super-reference,
> > which
> > points to the currently-alive actor from a given supervisor? But then I
> > might
> > send something which asynchronously kills the actor, and I'll get a fresh
> > actor for the next line, which seems like a bad thing. There needs to be
> > some
> > clean semantics for "Give me a reference to the currently-alive version
> > of this actor" which doesn't rely on a global, flat registry.
>
> I don't know of a better solution. This is the same approach Erlang uses.
> The only evolution it's seen in recent history is systems like Ulf Wiger's
> gproc.
Looking again, maybe the supervisor already does this?
supervisor = Sheen.supervise "Charlie Sheen"
charlie = supervisor.actor
This would solve both problems, right? (Assuming the supervisor is itself
threadsafe.) It could use some sugar, but I'm not entirely sure how.
> > And a thought: I just had every method return a future. If people wanted
> > something to run asynchronously, all they had to do is ignore the future.
> > The
> > downside is that this makes it hard to force things to be synchronous. I
> > actually thought of this as a good thing -- if I make the call up at the
> > top
> > of a method, and don't use the result till the bottom, that's some
> > surprise parallelism right there. The biggest problem is that if there's
> > an exception,
> > you don't know about it until the future is resolved.
>
> That's an interesting approach, but a bit different than the one I'm
> shooting for in Celluloid, where I want concurrent objects to quack like
> normal Ruby objects as much as possible.
And this does quack like a normal Ruby object, unless something goes wrong and
an exception is raised. But I was never quite satisfied with how exceptions
were dealt with. For one thing, it's not OK that someone might ignore a future
and never see the exception.