Thread overview | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 20, 2004 the $ token | ||||
---|---|---|---|---|
| ||||
disclaimer: sorry if it has been mentioned before how about adapting the $ token to convert anything to a string ? like int foo = 5; char[] bar = $foo; // bar == "5" i dont think this would be a large problem to implement whilst BASIC dudes would instantly know it's sth bout strings :] in BASIC you read a$ as 'a string'. that's my vote in the $ war ;] |
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to h3r3tic | Sorry mate, but that sounds like a ridiculously cheap waste of an operator that we may well find use for - e.g. serialisation, built-in rexex, ... - at a later stage. What's wrong with have a toString() shim function, defined for objects and for all built-in types. (In fact don't we have that already? It's been a while since I've delved into the bowels of Phobos ...) "h3r3tic" <h3r3tic@dev.null> wrote in message news:cg41l1$2u3m$1@digitaldaemon.com... > disclaimer: sorry if it has been mentioned before > > > how about adapting the $ token to convert anything to a string ? like > > int foo = 5; > char[] bar = $foo; > > // bar == "5" > > i dont think this would be a large problem to implement whilst BASIC dudes would instantly know it's sth bout strings :] in BASIC you read a$ as 'a string'. > > that's my vote in the $ war ;] |
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | Matthew wrote:
> Sorry mate, but that sounds like a ridiculously cheap waste of an operator that we may well find use for - e.g.
> serialisation, built-in rexex, ... - at a later stage.
i dunno bout built-in rexex(regexp?) but for serialization ? cmon... i'd rather have a function serialize() and $ for strings instead of toString() for strings and $ for serialization... i mean, how often do you perform each of those ? most ppl probably don't do as much serialization as string conversion. using $ for serialization would be a waste IMHO...
could u give some more details about the "rexex" thingie ?
|
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to h3r3tic | In article <cg490p$nk$1@digitaldaemon.com>, h3r3tic says... >could u give some more details about the "rexex" thingie ? Assuming that "regexp" was intended, there is plenty of information about regular expressions on the web, including this nice one: http://gnosis.cx/publish/programming/regular_expressions.html. Just google "regular expressions" for more. For D, however, I plan something more ambitious in the long term - Unicode Regular Expressions - the definition of which is found in Unicode Technical Standard #18 at http://www.unicode.org/reports/tr18/. (Check it out if interested). However, regular expressions (whether ASCII or Unicode) don't seem to require any special characters outside of a string literal. Sure, '$' means "end of string", but you'd pass the regexp pattern inside a string literal. I don't believe that a change to D lexing involving $ would be a good idea here. But I don't want $ used for toString() either. We've only got a few unused ASCII symbols left, so I think we should save them until something /really/ important crops up. Arcane Jill |
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to h3r3tic | "h3r3tic" <h3r3tic@dev.null> wrote in message news:cg490p$nk$1@digitaldaemon.com... > Matthew wrote: > > Sorry mate, but that sounds like a ridiculously cheap waste of an operator that we may well find use for - e.g. serialisation, built-in rexex, ... - at a later stage. > > i dunno bout built-in rexex(regexp?) but for serialization ? cmon... i'd > rather have a function serialize() and $ for strings instead of > toString() for strings and $ for serialization... i mean, how often do > you perform each of those ? most ppl probably don't do as much > serialization as string conversion. using $ for serialization would be a > waste IMHO... > could u give some more details about the "rexex" thingie ? They were both simple "for instance"s thrown up on the spur of the moment. My central point, which I believe suffices, is that conversion to string is ably handled already by toString() functions. (Which are far more readable than a non-C-language-standard operator, as well.) |
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arcane Jill | Arcane Jill wrote: > For D, however, I plan something more ambitious in the long term - Unicode Regular Expressions - the definition of which is found in Unicode Technical Standard #18 at http://www.unicode.org/reports/tr18/. (Check it out if interested). It would be nice to have general regex pattern search operating on any array. Imagine searching patterns in a chess position array or .... -- Helmut Leitner leitner@hls.via.at Graz, Austria www.hls-software.com |
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to h3r3tic | It is a goof idea to make the string conversion a little easyer. For example, when writing a web application, then one must write a lot of string conversions. But I must agree also, that every symbol is very valuable. One option is to make the conversion automatic. I mean int foo = 5; char[] bar = ""~foo; Because usually it is something like: return "my granny is "~toString(age)~" old"; it could be just: return "my granny is "~age~" old"; It is easyer to write, but harder to read and to understand the code. But it is an idea, isn't it? In article <cg41l1$2u3m$1@digitaldaemon.com>, h3r3tic says... > >disclaimer: sorry if it has been mentioned before > > >how about adapting the $ token to convert anything to a string ? like > >int foo = 5; >char[] bar = $foo; > >// bar == "5" > >i dont think this would be a large problem to implement whilst BASIC dudes would instantly know it's sth bout strings :] in BASIC you read a$ as 'a string'. > >that's my vote in the $ war ;] |
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to Arcane Jill | "Arcane Jill" <Arcane_member@pathlink.com> wrote in message news:cg4b5r$1o0$1@digitaldaemon.com... > But I don't want $ used for toString() either. We've only got a few unused ASCII > symbols left, so I think we should save them until something /really/ important > crops up. I'm holding it in reserve for a special purpose. Whenever you use the $ in a D program, you have to send $1 to Digital Mars. I should patent that idea, after all, if Amazon got a patent for clicking a mouse button, why not? <g> |
August 20, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to _ | You could swritef(), which would be clear, and would probably be less abusive to the heap to boot! "_" <__member@pathlink.com> wrote in message news:cg5425$ds2$1@digitaldaemon.com... > It is a goof idea to make the string conversion a little easyer. For example, when writing a web application, then one must write a lot of string conversions. > > > But I must agree also, that every symbol is very valuable. > One option is to make the conversion automatic. > I mean > int foo = 5; > char[] bar = ""~foo; > Because usually it is something like: > return "my granny is "~toString(age)~" old"; > it could be just: > return "my granny is "~age~" old"; > > It is easyer to write, but harder to read and to understand the code. > > But it is an idea, isn't it? > > > In article <cg41l1$2u3m$1@digitaldaemon.com>, h3r3tic says... > > > >disclaimer: sorry if it has been mentioned before > > > > > >how about adapting the $ token to convert anything to a string ? like > > > >int foo = 5; > >char[] bar = $foo; > > > >// bar == "5" > > > >i dont think this would be a large problem to implement whilst BASIC dudes would instantly know it's sth bout strings :] in BASIC you read a$ as 'a string'. > > > >that's my vote in the $ war ;] > > |
August 21, 2004 Re: the $ token | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | Matthew wrote:
> You could swritef(), which would be clear, and would probably be less abusive to the heap to boot!
but it's still so C-ish. being able to do "foo " ~ 5 ~ whatever ~ " bar" would be a GoodThing for projects like DSP.
|
Copyright © 1999-2021 by the D Language Foundation