I am getting this error while executing ire in emacs shell process:
bash-3.2$ ire
Reia Interactive Shell (prerelease)
Running on
=ERROR REPORT==== 11-Feb-2009::23:46:08 ===
Error in process <0.27.0> with exit value: {badarg,[{erlang,register,
[user,<0.28.0>]},{user,start_port,1}]}
as running ire:start(). from erlang shell works fine, I presume it
might be a problem with executing this:
user_drv:start('tty_sl -c -e', {ire, start, []}).
Hi, Tony!
Want to know your opinion concerning blocks.
Are they meant to be just a syntactic sugar to passing a lambda as an argument? i.e. is
o.f(2) {|x| x*3} the same as
o.f(2, fun(x) {x*3})
Will f/arity be the same in both cases:
def f(a, &b)
def f(a, b)
?
Since lamdas work perfectly fine, i can hurl my effort to tune the syntax to allow blocks
I've hacked Reia to allow blocks, added some tests, but Block is just a last Argument in my implementation (arity
gets +1):
module BlockTest
def function_taking_block(a, &b)
a + b(a)
BlockTest.function_taking_block(2, fun(x){x*2}) # 6
Lists funcall dispatch have been fixed to pass a block as a lambda argument:
[1, 2, 3].map {|x| x*2} # [2,4,6]
And this snowball touched reia_class.erl and reia.erl a bit, too.
Pull from github.com/pirj/reia if there's any interest.
It's really messy in reia_parser.yrl, but i suggest this can be simplified a bit.
The're one more major thing i'm concerned, lambda context, i.e. will lambda ever see the caller's bindings?
It may confuse and wonder why this is required at all, but i felt this will be vital required to write readable RSpec-
like tests:
Behave.context('A User instance') do
user = User.find(~first)
should('return its full name') do
assert('John Doe' == user.full_name)
should('return its email address') do
assert('Joh...@gmail.com' == user.email)
Here, a user is fetched only once, and used multiple times.
'user' is used inside 'should's passed lambda
Syntax looks not bad when there's only one var:
should('return its full name', user) do |user|
assert('John Doe' == user.full_name)
but when there's more it's getting really messy:
should('return its full name', user1, user2) do |user1, user2|
assert(user1.surname == user2.surname)
Phil
Cheers, Phil
Phil
>
Cheers, Phil
It's a pity!
I've hacked Reia to allow blocks, added some tests, but Block is just a last Argument in my implementation (arity
gets +1):
And this snowball touched reia_class.erl and reia.erl a bit, too.
Pull from github.com/pirj/reia if there's any interest.
It's really messy in reia_parser.yrl, but i suggest this can be simplified a bit.
The're one more major thing i'm concerned, lambda context, i.e. will lambda ever see the caller's bindings?
Syntax looks not bad when there's only one var:
should('return its full name', user) do |user|
assert('John Doe' == user.full_name)
but when there's more it's getting really messy:
should('return its full name', user1, user2) do |user1, user2|
assert(user1.surname == user2.surname)
> > I've hacked Reia to allow blocks, added some tests, but Block is just a
> > last Argument in my implementation (arity
> > gets +1):
> As soon as you try to add splats, default values, or keyword arguments
> though, this whole approach is going to cease to work.
No doubt
> What did you change in the parser?
http://github.com/pirj/reia/commit/8978db10ace33189ba0604568a5a74ebc79042ce#diff-0
initial support for "&" terminal
http://github.com/pirj/reia/commit/60f7512cd342e93ef9773be7c0197eab87c29027#diff-0
Top half takes care of
def f(a, &b) declaration, supporting "&" symbol
Code is messy here, i haven't found a way to get rid of fexprs
Bottom part adds block as lambda to Argument list (thing i shouldn't do)
> In the future you might want to push a remote branch for this sort of thing
> (i.e. experimental changes you'd like other people to check out) so you can
> keep your master clean for me to pull from if you have changes ready to be
> merged into my repo. And if I like your experiment, I can pull from your
> experimental branch.
Sounds good.
> Tony Arcieri