Jump to page: 1 2
Thread overview
C++0x now with lambda and closure
Mar 31, 2008
guslay
Mar 31, 2008
Jacob Carlborg
Mar 31, 2008
downs
Apr 01, 2008
Ary Borenszweig
Apr 01, 2008
Robert Fraser
Apr 01, 2008
BCS
Apr 01, 2008
Ralf Schneider
Apr 02, 2008
Robert M. Münch
Apr 04, 2008
bearophile
Apr 04, 2008
bearophile
Apr 04, 2008
Charles D Hixson
Mar 31, 2008
Sean Kelly
Apr 04, 2008
janderson
Apr 10, 2008
Bruno Medeiros
Apr 11, 2008
Sean Kelly
Apr 11, 2008
Bruno Medeiros
March 31, 2008
For those keeping track...

http://herbsutter.spaces.live.com/

Crazy syntax, at least it looks better than boost.

March 31, 2008
guslay wrote:
> For those keeping track...
> 
> http://herbsutter.spaces.live.com/
> 
> Crazy syntax, at least it looks better than boost.
> 

I like the C# syntax:
listOfFoo.Where(x => x.size > 10);

even better if you could have this syntax (but perhaps it won't work):
listOfFoo.Where((x) x.size > 10);

I would be nice to have that in D
March 31, 2008
Jacob Carlborg wrote:
> guslay wrote:
>> For those keeping track...
>>
>> http://herbsutter.spaces.live.com/
>>
>> Crazy syntax, at least it looks better than boost.
>>
> 
> I like the C# syntax:
> listOfFoo.Where(x => x.size > 10);
> 
> even better if you could have this syntax (but perhaps it won't work):
> listOfFoo.Where((x) x.size > 10);
> 
> I would be nice to have that in D

Well, _kinda_ with tools :)

listOfFoo /select/ ex!("x -> x.size > 10");

:)

 --downs
March 31, 2008
== Quote from guslay (guslay@gmail.com)'s article
> For those keeping track...
> http://herbsutter.spaces.live.com/
> Crazy syntax, at least it looks better than boost.

Pretty cool, but still not as nice as D's delegates.  From the
proposal (5.1.1): "Each lambda expression has a  unique type.
Except as specified below, the type of the closure object is
unspecified."  This suggests that a closure really isn't intended
to escape the scope in which it is declared, because there's
no easy way to declare one (I can imagine some fancy template
tricks to do so, but I'm ignoring them).

This is actually somewhat interesting because the syntax for
declaring closures in C++ seems to allow for this by providing
a way for automatic local data to be saved (the capture list).
Perhaps they'll get another shot in the arm in the next iteration
of C++ to become more like full closures.  Or maybe this was
enough of a language change and the rest is expected to be
taken care of in library code?  I haven't been following the
progress of 0x in the past year or two so I really couldn't
say what the reasoning is here.

Interestingly, this proposal Herb mentions has removed 'auto' as a storage class:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2546.htm

This seems completely unnecessary to me--the D way makes much
more sense.  Simply omit the type portion of the declaration and the
type is inferred.  I wonder what the reasoning was here?

It's kind of weird, but now that the new spec is basically finalized I find myself having trouble finding many features that I'm actually enthusiastic about.  Most of the few features that sound really cool in theory already exist in D and their syntax there is much nicer.  And some of the proposals are such obvious extensions of other proposals that their existence simply stands as a testament to the bureaucracy involved in the standardization process.  This one, for example:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2547.htm

After more than sixteen years with the language it feels strange to say that I actually feel somewhat relieved that my professional work has led me away from C++ recently.


Sean
April 01, 2008
downs wrote:
> Jacob Carlborg wrote:
>> guslay wrote:
>>> For those keeping track...
>>>
>>> http://herbsutter.spaces.live.com/
>>>
>>> Crazy syntax, at least it looks better than boost.
>>>
>> I like the C# syntax:
>> listOfFoo.Where(x => x.size > 10);
>>
>> even better if you could have this syntax (but perhaps it won't work):
>> listOfFoo.Where((x) x.size > 10);
>>
>> I would be nice to have that in D
> 
> Well, _kinda_ with tools :)
> 
> listOfFoo /select/ ex!("x -> x.size > 10");
> 
> :)

Except that Visual Studio offers you autocompletion. But in strings...
April 01, 2008
downs wrote:
> Jacob Carlborg wrote:
>> guslay wrote:
>>> For those keeping track...
>>>
>>> http://herbsutter.spaces.live.com/
>>>
>>> Crazy syntax, at least it looks better than boost.
>>>
>> I like the C# syntax:
>> listOfFoo.Where(x => x.size > 10);
>>
>> even better if you could have this syntax (but perhaps it won't work):
>> listOfFoo.Where((x) x.size > 10);
>>
>> I would be nice to have that in D
> 
> Well, _kinda_ with tools :)
> 
> listOfFoo /select/ ex!("x -> x.size > 10");
> 
> :)
> 
>  --downs

One of my D library ideas that fell by the wayside was to make a compile-time SQL parser. So you could do something like:

string[] results = Query!("
        SELECT groups.name
            FROM groups
            INNER JOIN employees ON employees.groupId = groups.id,
            GROUP BY employees.groupId
            HAVING avg(employees.salary) > 50000
            WHERE group.name != "Accounting" -- Nobody likes them
            ORDER BY group.name
    ");

(or something like that; my SQL's a bit rusty). Ideally, you could have an arbitrarily complex query including subqueries. Query would be a template of some sort... not sure exactly how this would work... but that's my pipe dream, anyway.
April 01, 2008
Robert Fraser wrote:

> One of my D library ideas that fell by the wayside was to make a compile-time SQL parser. So you could do something like:
> 
> string[] results = Query!("
>         SELECT groups.name
>             FROM groups
>             INNER JOIN employees ON employees.groupId = groups.id,
>             GROUP BY employees.groupId
>             HAVING avg(employees.salary) > 50000
>             WHERE group.name != "Accounting" -- Nobody likes them
>             ORDER BY group.name
>     ");
> 
> (or something like that; my SQL's a bit rusty). Ideally, you could have an arbitrarily complex query including subqueries. Query would be a template of some sort... not sure exactly how this would work... but that's my pipe dream, anyway.

I have wanted to make a template that lets you define a DB class with stored procedures accessed through methods. It would work a lot like the above but would optimize the queries at compile time.

The parser for either case would be big, slow and a memory hog but it can be built.
April 01, 2008
>
> One of my D library ideas that fell by the wayside was to make a compile-time SQL parser. So you could do something like:
>
> string[] results = Query!("
>         SELECT groups.name
>             FROM groups
>             INNER JOIN employees ON employees.groupId = groups.id,
>             GROUP BY employees.groupId
>             HAVING avg(employees.salary) > 50000
>             WHERE group.name != "Accounting" -- Nobody likes them
>             ORDER BY group.name
>     ");
>
> (or something like that; my SQL's a bit rusty). Ideally, you could have an arbitrarily complex query including subqueries. Query would be a template of some sort... not sure exactly how this would work... but that's my pipe dream, anyway.

Have a look at Ultimate++:
http://www.ultimatepp.org/src$Sql$SqlExp$en-us.html
but in C++ and without strings like:

Select(COLUMN)
.From(TABLE)

.Where(COLUMN == (Select(COLUMN1).From(TABLE1) -

       Select(COLUMN2).From(TABLE2)))




April 02, 2008
On Tue, 01 Apr 2008 20:04:10 +0200, Ralf Schneider <ralfs72_at_@gmx.net> wrote:

> Have a look at Ultimate++:
> http://www.ultimatepp.org/src$Sql$SqlExp$en-us.html

Hi, that's an interesting one. Any experience with this toolkit?

-- 
Robert M. Münch
Management & IT Freelancer
http://www.robertmuench.de
April 04, 2008
guslay wrote:
> For those keeping track...
> 
> http://herbsutter.spaces.live.com/
> 
> Crazy syntax, at least it looks better than boost.
> 

Yet another C++ hack, D does it the correct way.

Seriously though, I look forward to the day I never have to work with a boost:bind or loki:functor again.

-Joel
« First   ‹ Prev
1 2