November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | davepermen wrote:
> how about ~> and <~ ?
That could cause a parsing problem with legal expressions such as:
if(foo<~0) { // a.k.a. (foo < ~0)
....
}
|
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | davepermen wrote:
> how about ~> and <~ ?
<- is ambiguous.
a<-b could mean a <- b or a < (-b)
More alternatives:
a <* b
a *> b
or
a <+ b
a +> b
or
a %> b
a <% b
The +> variant doesn't look too bad, but I still prefer the #>, because the # isn't used anywhere else in the language. So you cannot confuse it with an arithmetic expression of some kind.
Hauke
|
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hauke Duden | i haven't written <-, but <~.. but its as ambiguous:D i just don't like the way the non-ambiguous ones look like.. how about making it one direction only? inStream ~> intData ~> stringData ~> outStream; textFile("obj.txt") ~> objType ~> binFile("obj.data"); a simple converter:D so a general commandline login statement would then look like this: "Hello, Please Enter your Username:" ~> stdOut; stdIn ~> userName ~> \n; "And now your Password, please:" ~> stdOut; stdIn ~> userPassword ~> \n; if(userName in userList && userList[userName].passWord = userPassword) { "Welcome, " ~> userName ~> " on D OS" \n ~> stdOut; } something of that kind.. btw, its fun to think about an OS written in D.. what shall i call it? DOS? :D In article <boqqos$1ems$1@digitaldaemon.com>, Hauke Duden says... > >davepermen wrote: >> how about ~> and <~ ? > ><- is ambiguous. > >a<-b could mean a <- b or a < (-b) > >More alternatives: > >a <* b >a *> b > >or > >a <+ b >a +> b > >or > >a %> b >a <% b > >The +> variant doesn't look too bad, but I still prefer the #>, because the # isn't used anywhere else in the language. So you cannot confuse it with an arithmetic expression of some kind. > >Hauke |
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | >so a general commandline login statement would then look like this:
>
>"Hello, Please Enter your Username:" ~> stdOut;
>stdIn ~> userName ~> \n;
>"And now your Password, please:" ~> stdOut;
>stdIn ~> userPassword ~> \n;
>
>if(userName in userList && userList[userName].passWord = userPassword) {
>"Welcome, " ~> userName ~> " on D OS" \n ~> stdOut;
>}
I don't get the line "stdIn ~> userName ~> \n;". Does it mean read until \n?
|
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hauke Duden | >a <* b so b is a pointer and you want du dereference it? >a <+ b this gets interesting if you use literals a <+ 5 which is a < +5 >The +> variant doesn't look too bad, but I still prefer the #>, because the # isn't used anywhere else in the language. So you cannot confuse it with an arithmetic expression of some kind. °, µ or § isn't used as well. |
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to davepermen | davepermen wrote: > i haven't written <-, but <~.. but its as ambiguous:D Whooops. Sorry ;) > i just don't like the way the non-ambiguous ones look like.. > > how about making it one direction only? You would have to read pull-lines from left to right and push-lines from right to left. That's inconsistent and burdensome to read. The right side might be scrolled out of the window for long lines, so you would only see a nonsensical chain of values, without knowing where they actually go. Naaah, I think we need two different operators. Hauke |
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Becker | Matthias Becker wrote: >>a <* b > > > so b is a pointer and you want du dereference it? Ouch, you're right. > >>a <+ b > > this gets interesting if you use literals > > a <+ 5 > > which is a < +5 There is a unary + operator? [...looks through docs...]. It seems that there is. Interesting. Does it actually do anything, or is it simply there because there is also a unary -? Anyway, you're right, of course. <+ seems to be out of the question. >>The +> variant doesn't look too bad, but I still prefer the #>, because the # isn't used anywhere else in the language. So you cannot confuse it with an arithmetic expression of some kind. > > °, µ or § isn't used as well. And your point is? ;) Hauke |
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthias Becker | "Matthias Becker" <Matthias_member@pathlink.com> wrote in message news:bor3o9$1s40$1@digitaldaemon.com... > >a <* b > > so b is a pointer and you want du dereference it? > >a <+ b > this gets interesting if you use literals > > a <+ 5 > > which is a < +5 > > >The +> variant doesn't look too bad, but I still prefer the #>, because the # isn't used anywhere else in the language. So you cannot confuse it with an arithmetic expression of some kind. > > °, µ or § isn't used as well. ~ is bad enough, on a Norwegian keyboard it is a dead key. (Alt Gr + ~) release (SPACE) ° and µ does not even appear on my keyboard. §@# works. And can be displayed in 7-bit ASCII. Can ~ be displayed on 7-bit ASCII terminals? I doubt it. Roald |
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Roald Ribe | Roald Ribe wrote: > ~ is bad enough, on a Norwegian keyboard it is a dead key. > (Alt Gr + ~) release (SPACE) <snip> > Can ~ be displayed on 7-bit ASCII terminals? I doubt it. Jepp. ~ has ASCII code 126, so it will fit into 7 bits. The keyboard-issue is more important, I think. A week or so ago someone reported that it is impossible to type ~ using italian keyboards (except using the ALT+<ASCIICode> trick that works for all ASCII characters). Seems like ~ is one of those characters that could cause a lot of problems with an international audience. Maybe it would be a good idea to find a replacement for ~. It is the concatenation operator, after all, and it will probably be used often in everyday coding, so it should be something that most people can easily type. Hauke |
November 11, 2003 Re: stream operator suggestions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hauke Duden | Hauke Duden wrote:
> The keyboard-issue is more important, I think. A week or so ago someone reported that it is impossible to type ~ using italian keyboards (except using the ALT+<ASCIICode> trick that works for all ASCII characters). Seems like ~ is one of those characters that could cause a lot of problems with an international audience.
>
> Maybe it would be a good idea to find a replacement for ~. It is the concatenation operator, after all, and it will probably be used often in everyday coding, so it should be something that most people can easily type.
This is a fun subject because everybody can have an opinion, and no one is correct. I hope Walter puts his foot down soon. :-)
In the meantime, may I suggest an alternative?
Comcatenation: :+ (COLON PLUS)
Rationale: + is used in many languages for concatenating things. It's not entirely accurate since addition and concatenation are two different concepts. Making a new operator which still contains the + makes it familiar for users of those other languages but still different enough to point out that it's not an addition.
Extract operator: :> (COLON GREATER-THAN)
Inject operator: :< (COLON LESS-THAN)
Rationale: Familiarity for C++ programmers, but still not overloading multiple functionalities on a single operator (C++ seems to love that, and it's one of the reasons I can't stand that language). The bracket points in the direction of data flow.
An alternative to :< would be <: but personally I this that always having : as a prefix for a whole new set of operators is advantageous.
Well, those are my suggestions. Have fun. :-)
Elias
|
Copyright © 1999-2021 by the D Language Foundation