Re: Lambda syntax, etc

2009-02-04 Thread Nick Sabalausky
"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

Re: Lambda syntax, etc

2009-02-04 Thread hsyl20
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, > (

Re: Lambda syntax, etc

2009-02-04 Thread Jarrett Billingsley
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

Re: Lambda syntax, etc

2009-02-04 Thread Bill Baxter
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

Re: Lambda syntax, etc

2009-02-04 Thread Nick Sabalausky
"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'

Re: Lambda syntax, etc

2009-02-04 Thread BCS
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

Re: D versus Objective C Comparison

2009-02-04 Thread Nick Sabalausky
"John Reimer" wrote in message news:28b70f8c139c58cb5508b9b1b...@news.digitalmars.com... > Hello Bill, > >> On Thu, Feb 5, 2009 at 3:55 AM, Nick Sabalausky wrote: >> >>> "Michel Fortin" wrote in message >>> news:gmbt40$18p...@digitalmars.com... >>> Perhaps it's offtopic in a D forum, but y

Re: Lambda syntax, etc

2009-02-04 Thread Bill Baxter
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

Re: Lambda syntax, etc

2009-02-04 Thread Bill Baxter
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

Re: Lambda syntax, etc

2009-02-04 Thread Nick Sabalausky
"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

Re: Lambda syntax, etc

2009-02-04 Thread Nick Sabalausky
"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'

Re: Lambda syntax, etc

2009-02-04 Thread Nick Sabalausky
"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,

Re: Scientific computing with D

2009-02-04 Thread dsimcha
== Quote from Don (nos...@nospam.com)'s article > As a first step, I created a wiki page and copied your list to it. > http://www.prowiki.org/wiki4d/wiki.cgi?ScientificLibraries > I think it would be really useful to fill in the contents of each of > these libraries (as I've done for mine), so that

Re: Inline assembler in D and LDC, round 2

2009-02-04 Thread Walter Bright
Frits van Bommel wrote: Is it really that hard? Can't you just detect this case (non-void function without a 'return' at the end but with inline asm inside)? Since the compiler should know the calling convention[1], the register that will contain the return value of the function should be a si

Re: D versus Objective C Comparison

2009-02-04 Thread John Reimer
Hello Bill, On Thu, Feb 5, 2009 at 3:55 AM, Nick Sabalausky wrote: "Michel Fortin" wrote in message news:gmbt40$18p...@digitalmars.com... Perhaps it's offtopic in a D forum, but you should use the class NSCharacterSet for that if you want to be efficient. There's a couple of methods in NSS

Re: Inline assembler in D and LDC, round 2

2009-02-04 Thread Frits van Bommel
Walter Bright wrote: Is the inline assembling actually done by the LLVM back end, or the LDC front end? The frontend turns it into an GCC-style asm statement (with explicit input and output constraints) that shows up as a function literal in the IR (only valid as target of a 'call' instructio

Re: Inline assembler in D and LDC, round 2

2009-02-04 Thread Frits van Bommel
Tomas Lindquist Olsen wrote: Now in Tango there's a bunch of code, like the following (copied from tango.math.IEEE.d) real ldexp(real n, int exp) /* intrinsic */ { version(Really_D_InlineAsm_X86) { asm { fild exp; fld n; fscale; fst

Re: Lambda syntax, etc

2009-02-04 Thread bearophile
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,

Re: Lambda syntax, etc

2009-02-04 Thread hsyl20
> 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

Re: Inline assembler in D and LDC, round 2

2009-02-04 Thread Walter Bright
Is the inline assembling actually done by the LLVM back end, or the LDC front end?

Re: Lambda syntax, etc

2009-02-04 Thread Yigal Chripun
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

Re: Lambda syntax, etc

2009-02-04 Thread BCS
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

Re: Lambda syntax, etc

2009-02-04 Thread Bill Baxter
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

Re: Lambda syntax, etc

2009-02-04 Thread BCS
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

Re: Lambda syntax, etc

2009-02-04 Thread Nick Sabalausky
"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

Re: Lambda syntax, etc

2009-02-04 Thread Yigal Chripun
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:

Inline assembler in D and LDC, round 2

2009-02-04 Thread Tomas Lindquist Olsen
Hello everybody. Here comes the second round of inline asm discussion related to LDC, the LLVM D Compiler. Last time was about naked inline asm and the problems it poses for a backend like LLVM. Since revision 920 in our mercurial tree, naked inline asm support is good enough that Don's Bigint cod

Re: D versus Objective C Comparison

2009-02-04 Thread Bill Baxter
On Thu, Feb 5, 2009 at 3:55 AM, Nick Sabalausky wrote: > "Michel Fortin" wrote in message > news:gmbt40$18p...@digitalmars.com... >> >> Perhaps it's offtopic in a D forum, but you should use the class >> NSCharacterSet for that if you want to be efficient. There's a couple of >> methods in NSStri

Re: D versus Objective C Comparison

2009-02-04 Thread Nick Sabalausky
"Michel Fortin" wrote in message news:gmbt40$18p...@digitalmars.com... > > Perhaps it's offtopic in a D forum, but you should use the class > NSCharacterSet for that if you want to be efficient. There's a couple of > methods in NSString accepting NSCharacterSet too which you may be > intereste

Re: Lambda syntax, etc

2009-02-04 Thread Nick Sabalausky
"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

Re: D versus Objective C Comparison

2009-02-04 Thread Chris R Miller
Sean Kelly wrote: Chris R Miller wrote: = Short Story = I needed to search through a String (NSString) specifically to know whether a character at a specific index is any one of a given set of characters. Rather than subclass NSString, I decided to make a category: > [snip] Won't

Re: Lambda syntax, etc

2009-02-04 Thread Andrei Alexandrescu
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 ==

Re: Lambda syntax, etc

2009-02-04 Thread BCS
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

Re: D versus Objective C Comparison

2009-02-04 Thread Sean Kelly
Chris R Miller wrote: Jacob Carlborg wrote: Walter Bright wrote: Setting aside the technical issues for the moment, isn't that exactly what inheritance is supposed to be good for? A few times I've had the need for this, I've always been able to solve the problem but it would have been easier

Re: Scientific computing with D

2009-02-04 Thread Daniel Keep
Don wrote: > As a first step, I created a wiki page and copied your list to it. > > http://www.prowiki.org/wiki4d/wiki.cgi?ScientificLibraries > > I think it would be really useful to fill in the contents of each of > these libraries (as I've done for mine), so that we can get a good idea > of

Re: Scientific computing with D

2009-02-04 Thread Don
Lars Kyllingstad wrote: I think D is, or at least could be, the scientific programming language of the future. Here's why -- and possibly how: A couple of years ago, I took a university class called Numerical Physics. After finishing the course, I was left with the impression that numerical c

Re: ch-ch-update: series, closed-form series, and strides

2009-02-04 Thread Joel C. Salomon
Andrei Alexandrescu wrote: > So should I change "series" with "sequence"? How about what I called > "ClosedFormSeries"? By that I meant a series, (pardon, sequence), in > which there is no recurrence formula - the nth element a_n can be > expressed in terms of n and a[0], ..., a[k] (a sort of "rand

Re: D versus Objective C Comparison

2009-02-04 Thread grauzone
Daniel Keep wrote: grauzone wrote: Nick Sabalausky wrote: [snip] Umm, go into class A and add whatever you need? Maybe I can't, because it's foreign code. Changing it might increase maintenance overhead, require recompilation of libraries, might introduce additional module dependencies, whic

Re: D versus Objective C Comparison

2009-02-04 Thread bearophile
Michel Fortin: > with the extension syntax I proposed for class extensions in > D, you wouldn't have that problem (if implemented correctly) because > the compiler would always know from where the function is comming and > could therfore generate code so that the right function is called even >

Re: D versus Objective C Comparison

2009-02-04 Thread Michel Fortin
On 2009-02-04 01:36:59 -0500, Chris R Miller said: Unfortunately, they aren't in sequential order in the ASCII table, so it's not as simple as determining if char c is numeric: if ( c > '0' && c < '9' ) // c is numeric Therefore, it's useful for searching quickly, without getting into the

Re: D versus Objective C Comparison

2009-02-04 Thread Michel Fortin
On 2009-02-04 04:13:38 -0500, bearophile said: Instead of using a "kitchen-sink" class, in D you can put such functionality into a module, like the string module of Phobos or similar libs. I don't know Object-C, what you have done looks like the "monkey patching" done sometimes in Ruby. Is

Lambda syntax, etc

2009-02-04 Thread 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 } It's shorter and less clutte

Re: D versus Objective C Comparison

2009-02-04 Thread bearophile
Chris R Miller: > As you can see, I added important functionality to the class NSString > without going through all the trouble to make a new class and type cast > between NSString and MyDerivedString all over the place. It's more > transparent, and it's far better than a global function, or pl

Re: ch-ch-update: series, closed-form series, and strides

2009-02-04 Thread Lars Kyllingstad
Andrei Alexandrescu wrote: Great! I didn't know (haven't learned college-level Math in English; sometimes I wonder how I fumbled through grad school without major misunderstandings). By the way, I might have been wrong with the name "series" itself. I thought "series" is something like a_n = f