[MacRuby-devel] NSSet and Set broken in MacRuby 0.5 final?
Hi there, today I updated my MacRuby installation from MacRuby 0.5b1 to 0.5 final. Sadly, this broke my class "MERStandard" which used a Set. My Cocoa app embeds the MacRuby.framework. I initialized an empty set like this, which worked fine with MacRuby 0.5b1 mySet = Set.new With MacRuby 0.5 final I am getting the following error: An exception occured: NameError uninitialized constant MERStandard::Set If I put a require 'set' at the top of my class file, I get the following error: An exception occured: LoadError no such file to load -- set Am I doing something wrong or was anything substantial changed in the relase version? Thanks and cheers Frank ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Feedback: Dispatch high-level wrappers
Hi Jordan,
On Feb 10, 2010, at 12:30 AM, Jordan K. Hubbard wrote:
> P.S. Is it just me, or do other people have a really hard time turning specs
> into usage-case examples when they read them?
In answer to your plea, I've not only commented up the Dispatch module with
examples:
http://svn.macosforge.org/repository/ruby/MacRuby/trunk/lib/dispatch/dispatch.rb
I've expanded them into a sample-macruby script:
http://svn.macosforge.org/repository/ruby/MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.rb
(also below)
Note that this requires the latest nightly to work, as I redid the semantics of
Dispatch.group.
Fairly minimal, but something to start with. Does that help?
-- Ernie P.
#!/usr/local/bin/macruby
require 'dispatch'
puts "\n Use Dispatch.async to do stuff in the background"
Dispatch.async { p "Did this later" }
sleep 0.1
puts "\n Use Dispatch.group to track when stuff completes"
g = Dispatch.group { p "Do this" }
Dispatch.group(g) { p "and that" }
g.wait
p "Done"
puts "\n Use Dispatch.fork to capture return values in a Future"
f = Dispatch.fork { 2+2 }
p f.value
puts " - pass a block to return the value asynchronously"
f.value { |v| p "Returns #{v}" }
sleep 0.1
puts "\n Use Dispatch.queue_for to create a private serial queue"
puts " - synchronizes access to shared data structures"
a = Array.new
q = Dispatch.queue_for(a)
puts " - has a (mostly) unique name:"
p q
q.async { a << "change me" }
puts " - uses sync to block and flush queue"
q.sync { p a }
puts "\n Use with a group for more complex dependencies, "
q.async(g) { a << "more change" }
Dispatch.group(g) do
tmp = "complex calculation"
q.async(g) { a << tmp }
end
puts " - uses notify to execute block when done"
g.notify(q) { p a }
q.sync {}
puts "\n Use Dispatch.wrap to serialize object using an Actor"
b = Dispatch.wrap(Array)
b << "safely change me"
p b.size # => 1 (synchronous return)
b.size {|n| p "Size=#{n}"} # => "Size=1" (asynchronous return)
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Feedback: Dispatch high-level wrappers
That's definitely a good start, yes, though I must confess to not quite understanding the dispatch.fork example? On Feb 12, 2010, at 10:20 AM, Ernest N. Prabhakar, Ph.D. wrote: > Note that this requires the latest nightly to work, as I redid the semantics > of Dispatch.group. > > Fairly minimal, but something to start with. Does that help? ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] Feedback: Dispatch high-level wrappers
Hi Jordan, On Feb 12, 2010, at 11:12 AM, Jordan K. Hubbard wrote: > That's definitely a good start, yes, though I must confess to not quite > understanding the dispatch.fork example? All Dispatch.fork does is allow you to access the return value of the block (whenever it is available), either synchronously or asynchronously. In other words, I'm trying to make Futures duck-type to Ruby threads, with allow a return 'value'. I've annotated the file with return values, which may make things a bit clearer. >> http://svn.macosforge.org/repository/ruby/MacRuby/trunk/sample-macruby/Scripts/gcd/dispatch_methods.rb Perhaps part of the problem is that I'm using the same method for return both synchronously (direct) and asynchronously (continuation passing style). It leads to a more concise API, and a fairly powerful pattern once you are used to it, but perhaps that is overly clever. What do you think? I'm also working on a full-fleged article that uses actual, y'know, sentences, which may help once it is done... -- Ernie P. ___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Re: [MacRuby-devel] NSSet and Set broken in MacRuby 0.5 final?
Hi Frank, On Feb 12, 2010, at 7:12 AM, Frank Illenberger wrote: > Hi there, > > today I updated my MacRuby installation from MacRuby 0.5b1 to 0.5 final. > Sadly, this broke my class "MERStandard" which used a Set. > My Cocoa app embeds the MacRuby.framework. I initialized an empty set like > this, which worked fine with MacRuby 0.5b1 > > mySet = Set.new > > With MacRuby 0.5 final I am getting the following error: > > An exception occured: NameError uninitialized constant MERStandard::Set > > If I put a > > require 'set' > > at the top of my class file, I get the following error: > > An exception occured: LoadError no such file to load -- set > > Am I doing something wrong or was anything substantial changed in the relase > version? In the final 0.5 release we decided to revert our NSSet-based implementation of set and use the pure-Ruby implementation, so you do need to require 'set'. If 'set' can't be found in your application bundle maybe it's because you did not embed the standard library? Laurent___ MacRuby-devel mailing list [email protected] http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
