From: Paul A. on
Hi,

Just a thin post in order to purpose this:

I think it could be cool to call lambda function just like: λ

Such as:

a = 0
my_while λ { a < 5 } do
puts a
a += 1
end

I think λ is more human then ->

Regards
--
Posted via http://www.ruby-forum.com/.

From: Robert Klemme on
2010/5/28 Paul A. <cyril.staff(a)gmail.com>:
> Just a thin post in order to purpose this:
>
> I think it could be cool to call lambda function just like: ë
>
> Such as:
>
> a = 0
> my_while  ë { a < 5 }  do
>   puts a
>   a += 1
> end
>
> I think ë is more human then ->

This might cause issues with encoding of the source code - I believe
it is unspoken agreement that programming languages use 7 bit ASCII as
least common denominator for encoding of keywords and control
structures. And the reason is that with that convention you have the
biggest chance of being robust against encoding differences (e.g. IIRC
7 bit ASCII is a subset even of UTF-8 and of course all the ISO 8859
encodings). There might even be systems that do not support an
encoding which knows the greek lambda. This would limit portability
of source code.

Maybe this is a topic for ruby-core (cross posted there).

Kind regards

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

From: Piyush Ranjan on
okay I have seen this in clojure also. sigma and likes. Can you please tell
me how to type it ? :P

Piyush

2010/5/28 Robert Klemme <shortcutter(a)googlemail.com>

> 2010/5/28 Paul A. <cyril.staff(a)gmail.com>:
> > Just a thin post in order to purpose this:
> >
> > I think it could be cool to call lambda function just like: ë
> >
> > Such as:
> >
> > a = 0
> > my_while ë { a < 5 } do
> > puts a
> > a += 1
> > end
> >
> > I think ë is more human then ->
>
> This might cause issues with encoding of the source code - I believe
> it is unspoken agreement that programming languages use 7 bit ASCII as
> least common denominator for encoding of keywords and control
> structures. And the reason is that with that convention you have the
> biggest chance of being robust against encoding differences (e.g. IIRC
> 7 bit ASCII is a subset even of UTF-8 and of course all the ISO 8859
> encodings). There might even be systems that do not support an
> encoding which knows the greek lambda. This would limit portability
> of source code.
>
> Maybe this is a topic for ruby-core (cross posted there).
>
> Kind regards
>
> robert
>
> --
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/
>
>

From: Caleb Clausen on
On 5/27/10, Paul A. <cyril.staff(a)gmail.com> wrote:
> Hi,
>
> Just a thin post in order to purpose this:
>
> I think it could be cool to call lambda function just like: ë
>
> Such as:
>
> a = 0
> my_while ë { a < 5 } do
> puts a
> a += 1
> end

Honestly, why is this better than:

a=0
while a<5 do
puts a
a+=1
end

This way is so much less noisy and more succinct. You could even leave
off the do.

lambdas should not be used to replace arbitrary expressions. Only
where you need them.

> I think ë is more human then ->

Idunno. It's just some (fairly arbitrary) greek letter. I find the
arrow a little more evocative myself.

Putting Robert's doubts about encoding issues aside, you can already
do this in both 1.8 and 1.9:

#encoding: utf-8
alias ë lambda
x=ë{ p :foo }
x.call #=> :foo

In 1.8, you do have to pass -Ku on the command line, tho.

I am with Piyush on the question of how you type these things, tho. My
keyboard only has ascii on it. I'm putting off adopting unicode until
a unicode keyboard is available.

From: Intransition on


On May 28, 2:37 am, "Paul A." <cyril.st...(a)gmail.com> wrote:
> Hi,
>
> Just a thin post in order to purpose this:
>
> I think it could be cool to call lambda function just like: λ
>
> Such as:
>
> a = 0
> my_while  λ { a < 5 }  do
>    puts a
>    a += 1
> end
>
> I think λ is more human then ->

For that matter, if we're going by similarity, doesn't /\ look much
more like λ than -> ?

f = /\(x){ x < 5 }

 |  Next  |  Last
Pages: 1 2 3
Prev: Insecure operation - chdir
Next: Reports & Graphs