Denis Koroskin Wrote:
> >> Could be used as follows:
> >>
> >> foo( (i) { ++i; } );
> >
> > Holy shi-
> > Now feel some real power, Luke. :)
> >
> > foo( i => ++i );
> >
> >> foo((i){ ++i; }); // error
> >> foo((i){ ++i; return;}); // unambiguous
> >> foo((i){ return ++i;}); // unambig
Kagamin:
> There is no error here, since there's no <- operator, the construct is
> unabiguous, it just looks weird.
In Fortress the syntax of this expression is OK:
x + 2 * 3
x + 2*3
This is a syntax error, because the spaces are misleading:
x+2 * 3
Bye,
bearophile
bearophile Wrote:
> Kagamin:
> > auto r = find(range, {a -> a.Weight <- 100});
>
> Take a look at how the Fortress language manages spaces inside expressions.
> It can find a syntax error there, because the spacing is misleading.
There is no error here, since there's no <- operator, the constru
Kagamin Wrote:
> > > auto r = find(range, {a -> a.Weight <- 100});
> >
> > Take a look at how the Fortress language manages spaces inside expressions.
> > It can find a syntax error there, because the spacing is misleading.
>
> There is no error here, since there's no <- operator, the construct
Kagamin:
> auto r = find(range, {a -> a.Weight <- 100});
Take a look at how the Fortress language manages spaces inside expressions. It
can find a syntax error there, because the spacing is misleading.
Bye,
bearophile
grauzone Wrote:
> > // syntax for lambda that contains a single expression, implicit return
> > (this is the most common case):
> > auto r = find!(a => a.Weight > 100)(range);
>
> I really like this one, but I'd prefer something like
> > auto r = find(range, {a -> a.Weight > 100});
>
> Note th
"grauzone" wrote in message
news:gmpgod$fe...@digitalmars.com...
> bearophile wrote:
>> Let's play more; then what do you think about (all the following are
>> legal):
>>
>> auto r1 = range.find({ x -> x.weight > 100 });
>> auto r2 = range.find({ x :: return x.weight > 100; });
>> auto r3 = rang
bearophile wrote:
grauzone Wrote:
I really like this one, but I'd prefer something like
> auto r = find(range, {a -> a.Weight > 100});
Note the -> instead of the =>, to avoid any ambiguities with the
comparison operator.
Let's play more; then what do you think about (all the following are l
bearophile:
> auto r1 = range.find((ArrayType1!(typeof(range)) x) { return x.weight > 100;
> });
Better:
auto r1 = range.find((BaseType1!(typeof(range)) x) { return x.weight > 100; });
Of course, you have to specify range twice there, and that's not good.
Bye,
bearophile
grauzone Wrote:
> I really like this one, but I'd prefer something like
> > auto r = find(range, {a -> a.Weight > 100});
>
> Note the -> instead of the =>, to avoid any ambiguities with the
> comparison operator.
Let's play more; then what do you think about (all the following are legal):
auto
// syntax for lambda that contains a single expression, implicit return (this
is the most common case):
auto r = find!(a => a.Weight > 100)(range);
I really like this one, but I'd prefer something like
> auto r = find(range, {a -> a.Weight > 100});
Note the -> instead of the =>, to avoid any a
Jarrett Billingsley:
> auto r = find!(\a -> a.Weight > 100)(range);
> [...]
>
> something(\a, b
> {
> stmt1;
> stmt2;
> });
This looks better to me (but I don't know if this is the best syntax, it's just
an idea):
// syntax for lambda that contains a single expression, implicit return (
On Mon, Feb 9, 2009 at 3:19 AM, Bartosz Milewski wrote:
> bearophile Wrote:
>> Now, back to the topic: putting arguments into a single () or {} instead of
>> a (){ return ;} (or with the => of C#) helps the eye see a single visual
>> object isntead of two, this helps the human parsing of the cod
Kagamin wrote:
Christopher Wright Wrote:
D:
void foo(void delegate(int) dg);
C#:
delegate void SomeName(int i);
void foo(SomeName dg);
Does C# 3 fix this? I've seen the new syntax for defining delegates, but
not for using them.
C# got anough rope for this :)
http://msdn.microsoft.com/en-us
Denis Koroskin Wrote:
> That was just an example. Those short lambdas are often used as predicates.
> Compare:
>
> findAll(array, (i) { i > 3; });
> findAll(array, (int i) { return i > 3; });
>
well... you pwnd me :)
Christopher Wright Wrote:
> D:
> void foo(void delegate(int) dg);
>
> C#:
> delegate void SomeName(int i);
> void foo(SomeName dg);
>
> Does C# 3 fix this? I've seen the new syntax for defining delegates, but
> not for using them.
C# got anough rope for this :)
http://msdn.microsoft.com/en-us/
On Mon, 09 Feb 2009 13:24:46 +0300, Kagamin wrote:
Denis Koroskin Wrote:
Could be used as follows:
foo( (i) { ++i; } );
Holy shi-
Now feel some real power, Luke. :)
foo( i => ++i );
foo((i){ ++i; }); // error
foo((i){ ++i; return;}); // unambiguous
foo((i){ return ++i;}); //
Denis Koroskin Wrote:
> Could be used as follows:
>
> foo( (i) { ++i; } );
Holy shi-
Now feel some real power, Luke. :)
foo( i => ++i );
> foo((i){ ++i; }); // error
> foo((i){ ++i; return;}); // unambiguous
> foo((i){ return ++i;}); // unambiguous
bearophile Wrote:
> Now, back to the topic: putting arguments into a single () or {} instead of a
> (){ return ;} (or with the => of C#) helps the eye see a single visual object
> isntead of two, this helps the human parsing of the code, improving visual
> chunking and reducing noise.
I also be
> > You can use several "_", for instance:
> > scala> val a = List(10,5,2,48,75,84,96,85,3,21,52)
> > a: List[Int] = List(10, 5, 2, 48, 75, 84, 96, 85, 3, 21, 52)
> >
> > scala> val b = a reduceLeft (_ + _)
> > b: Int = 481
> >
> > The only problem is if you want to change arg order. In this case
Robert Fraser wrote:
BCS wrote:
Reply to Yigal,
Personally I prefer to have syntax for "blocks" like Ruby/smalltalk.
given the following example function:
int func(int a, delegate int(int) dg) { .. }
// call func with [something in this spirit is my favorite]:
func(someInt) { | int a, int b |
Christopher Wright wrote:
C#:
delegate void SomeName(int i);
void foo(SomeName dg);
Ugh, don't remind me!
BCS wrote:
Reply to Yigal,
Personally I prefer to have syntax for "blocks" like Ruby/smalltalk.
given the following example function:
int func(int a, delegate int(int) dg) { .. }
// call func with [something in this spirit is my favorite]:
func(someInt) { | int a, int b | return a+b; };
how
"Christopher Wright" wrote in message
news:gmfsqa$311...@digitalmars.com...
> Kagamin wrote:
>> Yeah, C# lambdas are the killer feature. Slick, readable, C-compatible.
>> Anders knows his job. Let's face it: delegate literals suck a little,
>> mixins as delegates suck a lot, the former is too v
Kagamin wrote:
Yeah, C# lambdas are the killer feature. Slick, readable, C-compatible. Anders
knows his job. Let's face it: delegate literals suck a little, mixins as
delegates suck a lot, the former is too verbose, the latter just sucks.
C# delegates in C# 2.0 are annoying. I try not to use
Reply to Yigal,
Personally I prefer to have syntax for "blocks" like Ruby/smalltalk.
given the following example function:
int func(int a, delegate int(int) dg) { .. }
// call func with [something in this spirit is my favorite]:
func(someInt) { | int a, int b | return a+b; };
how about requir
BCS wrote:
Why use this:
"func(someInt) { |a,b| return a+b; };"
when you can reuse syntax and get this for the same amount of typeing
"func(someInt) (a,b){ return a+b; };"
While I know the compiler could (should) know the difference easily
enough, my eyes want to parse that as a chained
hsyl20 wrote:
Nick Sabalausky Wrote:
The first notation "_ % 2 == 0" has no boilerplate and Scala is statically
typed (unlike Python).
I like that very much, especially since you can use either the implicit _ or
a manually named var. Although I would prefer something like "a", "b", etc,
(or ma
Reply to Andrei,
Kagamin wrote:
Also,
it is my perception (and not only mine) that C#'s creator completely
missed the power of templates and generative programming.
I have never met the man, but it is my impression that Anders didn't miss
the power, he just doesn't care for the paradigm. I
Reply to Nick,
This way, it's impossible to take valid code, add or remove a
semicolon, and still have valid code (which I think was your main
concern?).
I think that way can be made even stronger my making the delegate/block need
a trailing ';' (it's a function call after all) where a bare
grauzone wrote:
What I see above is a smörgåsbord of syntaxes that shoot all over the
proverbial barn door in the hope that one of them would strike
someone's fancy. That strikes me as a rather lousily done job. Also,
it is my
I find this statement rather ironic, because you also seem to be
On Thu, 05 Feb 2009 17:25:38 +0300, Andrei Alexandrescu
wrote:
Denis Koroskin wrote:
On Thu, 05 Feb 2009 12:32:15 +0300, Kagamin wrote:
bearophile Wrote:
C#2 has lambdas, and C#3 adds closures and more type inferencing, so
C#3+ supports the following syntaxes:
(int i) => { return i % 3
What I see above is a smörgåsbord of syntaxes that shoot all over the
proverbial barn door in the hope that one of them would strike someone's
fancy. That strikes me as a rather lousily done job. Also, it is my
I find this statement rather ironic, because you also seem to be quite
happy with
Andrei Alexandrescu>Beyond that, I don't feel that changes like moving the
parameters on one side or the other of "{" would be Earth-shattering.<
As you have seen there are several possible syntaxes for anonymous
functions/delegates/closures. And the current syntax already works, so I think
non
Denis Koroskin wrote:
On Thu, 05 Feb 2009 12:32:15 +0300, Kagamin wrote:
bearophile Wrote:
C#2 has lambdas, and C#3 adds closures and more type inferencing, so
C#3+ supports the following syntaxes:
(int i) => { return i % 3 == 1; } // C#2
i => i % 3 == 1 // C#3
i => { return i % 3 == 1; } /
Kagamin wrote:
bearophile Wrote:
C#2 has lambdas, and C#3 adds closures and more type inferencing, so C#3+
supports the following syntaxes:
(int i) => { return i % 3 == 1; } // C#2
i => i % 3 == 1 // C#3
i => { return i % 3 == 1; } // C#3, with statements too
To define a delegate o delegate cl
On Thu, 05 Feb 2009 12:32:15 +0300, Kagamin wrote:
bearophile Wrote:
C#2 has lambdas, and C#3 adds closures and more type inferencing, so
C#3+ supports the following syntaxes:
(int i) => { return i % 3 == 1; } // C#2
i => i % 3 == 1 // C#3
i => { return i % 3 == 1; } // C#3, with statements
bearophile Wrote:
> C#2 has lambdas, and C#3 adds closures and more type inferencing, so C#3+
> supports the following syntaxes:
> (int i) => { return i % 3 == 1; } // C#2
> i => i % 3 == 1 // C#3
> i => { return i % 3 == 1; } // C#3, with statements too
> To define a delegate o delegate closure:
"BCS" wrote in message
news:a6268ff24108cb552c70a0a...@news.digitalmars.com...
> Hello Nick,
>
>>> One #1 I'd be inclined to requier that the function be defined like
>>>
void DoIt(int delegate(int) dg...)
>>> D laready has this syntax for Typesafe Variadic Functions
>>> http://www.digi
Nick Sabalausky Wrote:
> > The first notation "_ % 2 == 0" has no boilerplate and Scala is statically
> > typed (unlike Python).
> >
>
> I like that very much, especially since you can use either the implicit _ or
> a manually named var. Although I would prefer something like "a", "b", etc,
> (
On Thu, Feb 5, 2009 at 1:20 AM, Nick Sabalausky wrote:
> >
> > Oh, and last semicolon of a function should be optional :-)
> >
> >{ int x; int y :: return x+y }
> >
>
> Now there's a language war waiting to happen ;)
Psh! All that has to happen grammatically is that instead of using a
raw se
On Thu, Feb 5, 2009 at 3:20 PM, Nick Sabalausky wrote:
>> K&R was like
>> int add(x,y)
>>int x;
>>int y;
>> { return x+y }
>>
>
> Oh that's right, I knew it was something funky like that. (That would be a
> "bad redundancy". /me nods to Walter's Dobbs article.)
Well the n
"Bill Baxter" wrote in message
news:mailman.651.1233813474.22690.digitalmar...@puremagic.com...
> On Thu, Feb 5, 2009 at 2:56 PM, Bill Baxter wrote:
>> On Thu, Feb 5, 2009 at 2:30 PM, Nick Sabalausky wrote:
> 2) A ruby-like syntax for delegate literals : {|a,b| return a+b;}
I don'
Hello Nick,
One #1 I'd be inclined to requier that the function be defined like
void DoIt(int delegate(int) dg...)
D laready has this syntax for Typesafe Variadic Functions
http://www.digitalmars.com/d/1.0/function.html
I'm not quite convinced either way on this. For what reasons do you
th
On Thu, Feb 5, 2009 at 2:56 PM, Bill Baxter wrote:
> On Thu, Feb 5, 2009 at 2:30 PM, Nick Sabalausky wrote:
2) A ruby-like syntax for delegate literals : {|a,b| return a+b;}
>>>
>>> I don't like that
>>>
>>
>> The thing I like about that is that it makes it much more clear at a glance
>> tha
On Thu, Feb 5, 2009 at 2:30 PM, Nick Sabalausky wrote:
>>> 2) A ruby-like syntax for delegate literals : {|a,b| return a+b;}
>>
>> I don't like that
>>
>
> The thing I like about that is that it makes it much more clear at a glance
> that the "a,b" or "int a, int b" is associated with the code blo
"Nick Sabalausky" wrote in message
news:gmdtjl$2f4...@digitalmars.com...
>
> // "func" used to disambiguate between function call and function
> declaration
> func add { |int <- int x, int y |
>return x+y;
> }
>
This one has the added benefit of making it easy to distinguish between an
att
"BCS" wrote in message
news:78ccfa2d39bdc8cb54edb3210...@news.digitalmars.com...
> Reply to Bill,
>
>>> I was about to say the same thing, but I think Yigal was just mixing
>> two distinct suggestions together:
>> 1) the trailing delegates proposal (aka ruby block) and
>
> I like that
>
Then we'
"hsyl20" wrote in message
news:gmd862$174...@digitalmars.com...
>> In D (with dlibs) it is:
>>
>> auto a = [97, 44, 67, 3, 22, 90, 1, 77, 98, 1078, 6, 64, 6, 79, 42];
>> auto b = a.filter((int i){return !(i % 2);});
>>
>> In Python:
>>
>> a = [97, 44, 67, 3, 22, 90, 1, 77, 98, 1078, 6, 64, 6, 79,
hsyl20:
> In Scala :
> The first notation "_ % 2 == 0" has no boilerplate and Scala is statically
> typed (unlike Python).
There's a subtle line between "no boilerplate" and "magic (variables)", and the
Python syntax is less magic there. So thanks but no thanks.
I like the type system of Scala,
> In D (with dlibs) it is:
>
> auto a = [97, 44, 67, 3, 22, 90, 1, 77, 98, 1078, 6, 64, 6, 79, 42];
> auto b = a.filter((int i){return !(i % 2);});
>
> In Python:
>
> a = [97, 44, 67, 3, 22, 90, 1, 77, 98, 1078, 6, 64, 6, 79, 42]
> b = [x for x in a if not(i % 2)]
In Scala :
val a = List(97, 44
Bill Baxter wrote:
On Thu, Feb 5, 2009 at 7:26 AM, BCS wrote:
Reply to Nick,
"Yigal Chripun" wrote in message
news:gmd0u8$fg...@digitalmars.com...
Andrei Alexandrescu wrote:
BCS wrote:
Hello bearophile,
I've taken a look at the syntax for lambda in other C-like
languages. This is fro
Reply to Bill,
I was about to say the same thing, but I think Yigal was just mixing
two distinct suggestions together:
1) the trailing delegates proposal (aka ruby block) and
I like that
2) A ruby-like syntax for delegate literals : {|a,b| return a+b;}
I don't like that
One #1 I'd be in
On Thu, Feb 5, 2009 at 7:26 AM, BCS wrote:
> Reply to Nick,
>
>> "Yigal Chripun" wrote in message
>> news:gmd0u8$fg...@digitalmars.com...
>>
>>> Andrei Alexandrescu wrote:
>>>
BCS wrote:
> Hello bearophile,
>
>> I've taken a look at the syntax for lambda in other C-like
Reply to Nick,
"Yigal Chripun" wrote in message
news:gmd0u8$fg...@digitalmars.com...
Andrei Alexandrescu wrote:
BCS wrote:
Hello bearophile,
I've taken a look at the syntax for lambda in other C-like
languages. This is from Functional Java:
http://functionaljava.org/examples#Array.filte
"Yigal Chripun" wrote in message
news:gmd0u8$fg...@digitalmars.com...
> Andrei Alexandrescu wrote:
>> BCS wrote:
>>> Hello bearophile,
>>>
I've taken a look at the syntax for lambda in other C-like languages.
This is from Functional Java:
http://functionaljava.org/examples#Array.fi
Andrei Alexandrescu wrote:
BCS wrote:
Hello bearophile,
I've taken a look at the syntax for lambda in other C-like languages.
This is from Functional Java:
http://functionaljava.org/examples#Array.filter
In Functional Java you can write this D syntax:
(int i, int j) { return i % 3 == j; }
as:
"Andrei Alexandrescu" wrote in message
news:gmclr4$2q3...@digitalmars.com...
> BCS wrote:
>> Hello bearophile,
>>
>>> I've taken a look at the syntax for lambda in other C-like languages.
>>> This is from Functional Java:
>>> http://functionaljava.org/examples#Array.filter
>>>
>>> In Functional J
BCS wrote:
Hello bearophile,
I've taken a look at the syntax for lambda in other C-like languages.
This is from Functional Java:
http://functionaljava.org/examples#Array.filter
In Functional Java you can write this D syntax:
(int i, int j) { return i % 3 == j; }
as:
{ int i, int j => i % 3 ==
Hello bearophile,
I've taken a look at the syntax for lambda in other C-like languages.
This is from Functional Java:
http://functionaljava.org/examples#Array.filter
In Functional Java you can write this D syntax:
(int i, int j) { return i % 3 == j; }
as:
{ int i, int j => i % 3 == j }
That s
I've taken a look at the syntax for lambda in other C-like languages.
This is from Functional Java:
http://functionaljava.org/examples#Array.filter
In Functional Java you can write this D syntax:
(int i, int j) { return i % 3 == j; }
as:
{ int i, int j => i % 3 == j }
It's shorter and less clutte
61 matches
Mail list logo