Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 15, 2006 $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
D dramatically improves the convenience of string handling over C++. But while I think using the library std.regexp is straightforward, obviously it just isn't gaining traction. People like the shortcut approaches Ruby and Perl use for regular expressions, hence the new D match-expression support. So, now we have: if (regular_expression ~~ string) { _match.pre _match.post _match.match(n) } Should we do some aliases: $` => _match.pre $' => _match.post $& => _match.match(0) $n => _match.match(n) ? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable? |
February 15, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
> D dramatically improves the convenience of string handling over C++. But while I think using the library std.regexp is straightforward, obviously it just isn't gaining traction. People like the shortcut approaches Ruby and Perl use for regular expressions, hence the new D match-expression support.
>
> So, now we have:
>
> if (regular_expression ~~ string)
> {
> _match.pre
> _match.post
> _match.match(n)
> }
>
> Should we do some aliases:
>
> $` => _match.pre
> $' => _match.post
> $& => _match.match(0)
> $n => _match.match(n)
>
> ? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable?
>
>
I don't have much todo with regexes .. but please .. the $ sign is ugly!!
|
February 15, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | "Walter Bright" <newshound@digitalmars.com> wrote in message news:dt088e$1svm$2@digitaldaemon.com... >D dramatically improves the convenience of string handling over C++. But while I think using the library std.regexp is straightforward, obviously it just isn't gaining traction. People like the shortcut approaches Ruby and Perl use for regular expressions, hence the new D match-expression support. > > So, now we have: > > if (regular_expression ~~ string) > { > _match.pre > _match.post > _match.match(n) > } > > Should we do some aliases: > > $` => _match.pre > $' => _match.post > $& => _match.match(0) > $n => _match.match(n) > > ? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable? Hmm... I don't do much with regular expressions, but the presence of too much sugar can be counterproductive; I personally think the standard lib is the place for that kind of thing. > > |
February 15, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <dt088e$1svm$2@digitaldaemon.com>, Walter Bright says... > >D dramatically improves the convenience of string handling over C++. But while I think using the library std.regexp is straightforward, obviously it just isn't gaining traction. People like the shortcut approaches Ruby and Perl use for regular expressions, hence the new D match-expression support. > >So, now we have: > > if (regular_expression ~~ string) > { > _match.pre > _match.post > _match.match(n) > } > >Should we do some aliases: > > $` => _match.pre > $' => _match.post > $& => _match.match(0) > $n => _match.match(n) > >? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable? > > Leave the $ sign for scripting languages... Thanks, Trevor Parscal |
February 15, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Wed, 15 Feb 2006 13:59:33 -0800, Walter Bright wrote: > D dramatically improves the convenience of string handling over C++. But while I think using the library std.regexp is straightforward, obviously it just isn't gaining traction. People like the shortcut approaches Ruby and Perl use for regular expressions, hence the new D match-expression support. > > So, now we have: > > if (regular_expression ~~ string) > { > _match.pre > _match.post > _match.match(n) > } Thanks for this Walter. Although it adds no new functionality to applications, it does say that D is a serious player in making string handling programs easier to write and maintain. I expect that std.regexp will still stay around and that this new feature is merely a portal into that library. > Should we do some aliases: > > $` => _match.pre > $' => _match.post > $& => _match.match(0) > $n => _match.match(n) > > ? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable? My first thought was "ouch! - not pleasant". After some consideration I'm now leaning towards the idea that we should hold off on implementing these shortcuts for now and wait to see if they are actually required or not. And then, if there is a crying need for them, to come up with a set of shortcuts that will be acceptable enough. Currently the '$' symbol is associated with arrays and lengths, and not as a general purpose lead-in character to symbol values. To mix these two disparate concepts in coders minds might not be fruitful. However, there may be other alternatives yet to be discovered, so the concept ought not to be totally abandoned just yet. -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocracy!" 16/02/2006 10:32:50 AM |
February 15, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | Derek Parnell wrote: > On Wed, 15 Feb 2006 13:59:33 -0800, Walter Bright wrote: > >> Should we do some aliases: >> >> $` => _match.pre >> $' => _match.post >> $& => _match.match(0) >> $n => _match.match(n) >> >> ? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable? > > My first thought was "ouch! - not pleasant". After some consideration I'm > now leaning towards the idea that we should hold off on implementing these > shortcuts for now and wait to see if they are actually required or not. And > then, if there is a crying need for them, to come up with a set of > shortcuts that will be acceptable enough. Agreed. > Currently the '$' symbol is associated with arrays and lengths, and not as > a general purpose lead-in character to symbol values. To mix these two > disparate concepts in coders minds might not be fruitful. However, there > may be other alternatives yet to be discovered, so the concept ought not to > be totally abandoned just yet. And this was my concern too. But perhaps this is a bridge best left ignored until there's a reason to jump. Sean |
February 15, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | In article <dt088e$1svm$2@digitaldaemon.com>, Walter Bright says... > >D dramatically improves the convenience of string handling over C++. But while I think using the library std.regexp is straightforward, obviously it just isn't gaining traction. People like the shortcut approaches Ruby and Perl use for regular expressions, hence the new D match-expression support. > >So, now we have: > > if (regular_expression ~~ string) > { > _match.pre > _match.post > _match.match(n) > } > >Should we do some aliases: > > $` => _match.pre > $' => _match.post > $& => _match.match(0) > $n => _match.match(n) > >? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable? On the contrary I think "$" is a very valuable symbol and should be used. Though the symbol "`" is very inconvenient (at least for spanish keyboard layout), ugly and could lead to confusion with "'" symbol - as I've seen many times and which I personally don't like to see used in such a way as "$'" -. Maybe "$[" and "$]", don't know. Just my opinion, Tom; |
February 16, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright wrote:
>
> Should we do some aliases:
>
> $` => _match.pre
> $' => _match.post
> $& => _match.match(0)
> $n => _match.match(n)
>
> ? Syntactic sugar is often a good idea, but at what point do they become cyclamates and cause cancer in laboratory animals? Will these $ tokens render D more accessible, but perhaps too unreadable?
Oh Bob no... Don't turn D into Perl. I like the $ for short cuts and such, but please no random symbols. I like $match.pre and $length, ect... but $& and $` don't mean anything to me!
|
February 16, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | "Derek Parnell" <derek@psych.ward> wrote in message news:15w2x5659i8ey$.p4zbzif24wfw$.dlg@40tude.net... > Thanks for this Walter. Although it adds no new functionality to applications, it does say that D is a serious player in making string handling programs easier to write and maintain. I expect that std.regexp will still stay around and that this new feature is merely a portal into that library. You're right in that all it really does is offer an easier way to get at std.regexp. > My first thought was "ouch! - not pleasant". After some consideration I'm > now leaning towards the idea that we should hold off on implementing these > shortcuts for now and wait to see if they are actually required or not. > And > then, if there is a crying need for them, to come up with a set of > shortcuts that will be acceptable enough. That's why I didn't do them yet. |
February 16, 2006 Re: $`, $', $&, $n - sugar or cyclamates? | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Demme | "John Demme" <me@teqdruid.com> wrote in message news:dt0fvp$23bj$1@digitaldaemon.com... > Oh Bob no... Don't turn D into Perl. I like the $ for short cuts and > such, > but please no random symbols. I like $match.pre and $length, ect... but > $& > and $` don't mean anything to me! <g>. I considered setting this up as a vote: Vote for 1: (1) If I wanted to write ugly programs I'd use Perl, not D. (2) Cool! I can now dump my Perl scripts and use D! |
Copyright © 1999-2021 by the D Language Foundation