July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Helmut Leitner | "Helmut Leitner" <helmut.leitner@chello.at> wrote in message news:3F236984.85F075D1@chello.at... > > > Walter wrote: > > > > Currently, there are 3 kinds of string literals: > > 'string' : wysiwyg strings > > "string" : escaped strings > > \ : single character strings > > > > There is no character literal syntax; 1 character long strings are implicitly converted to character literals based on context. Unfortunately, > > this leads to ambiguities with no reasonable way out (other than crafting > > arbitrary and confusing rules). > > Just a few thoughts. > > I like > 'string' : wysiwyg strings > "string" : escaped strings > the way it is (like Perl). > > Perl uses an alternative Syntax for various types of quoting > ("any nonwhitespace delimiter may be used in place of / "): > q/.../ single quote > qq/.../ double quote > qr/.../ quote regex expression > qx/.../ quote execution (instead of backtick) > qw/.../ word lists > which seems quite handy and open for extensions This is nice, but it won't work due to lexer confusion with: a = q/3; > On the other hand what would happen if you changed the semantics of > \n > to single character literal? The problems or ambiguities would > be different and perhaps easier to solve. It would work lexically, but I think it just wouldn't look right. > One may also note that VB uses ' and " identically. This is very > handy to build strings containing the opposite type of > quoting. > E. g. SQL: "SELECT * FROM Table WHERE Name='Peter';" > or: 'SELECT * FROM Table WHERE Name="Peter";' > This would also simplify building HTML > typical Perl: "<td width=\"1%\" align=\"right\">" > VBish: '<td width="1%" align="right">' > (of course no-one will ever use VB to generate HTML for other reasons) Using D to build HTML will happen with CGI apps. A single ' seems to be rare in HTML, so using 'string' for wysiwyg strings should work well. |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to sorry | <sorry@no.spam> wrote in message news:bg0ktu$2cpc$1@digitaldaemon.com... > What about a basic like syntax? (flames to /dev/null :-) > > char( ) || char(' ') > char(0x20) > char(\t) > > Can of chourse be made less verbose by shortening to > chr() or c(). > > Just an idea. It'll work, but too much typing! |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | "Burton Radons" <loth@users.sourceforge.net> wrote in message news:bg0l6c$2d3h$1@digitaldaemon.com... > All implicit casting rules are arbitrary. Incorrect even; the value of: > > ubyte a = 64; > ubyte b = 16; > ubyte c = a * b / b; > > Should be zero by a strict reading of intention, not sixty-four. I'm jiggy with it because its utility trumps its arbitrary and confusing rules in my book. I know. However, those are the C rules for expression evaluation. They are very, very ingrained in C programmers, and subtly changing them would be a disaster for D. > Likewise with preferring a function which takes a > single character argument over a function which takes a string. I can see many uses for such overloading. Also, there's: char[23] a; a[] = "b"; If "b" is a string, then a[] is set to "b\0\0\0\0\0....". If "b" is a single character, then a[] is set to "bbbbbb..."; > It's likely to be on every Romantic language's keyboard; you can look at their layouts at (http://www.microsoft.com/globaldev/reference/keyboards.aspx) using Internet Explorer only. But I wouldn't use the symbol; I don't think the problem, even if I agreed that it exists, merits the use of a new symbol. There hasn't been a new symbol in C in thirty years. C++ didn't add any new symbols. This conservatism can get out-of-hand, but unless if there is absolutely no way to do otherwise I don't think there should be new symbols. I feel the same way. |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to John Reimer | John Reimer wrote:
> With all those syntax highlighting text editors out there, I don't think it's much of a problem setting special colours for the string to make it more obvious for those with small/dense displays, no?
Legible colors use up very fast. They are simply too few. And when working in the sun, one can hardly distinguish even those. Besides, there must be someone with monochrome displays, no? Like, some people use an old 486-based Nokia organiser& cell phone, IIRC it's monochrome.
-i.
|
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | Burton Radons wrote: > Dollar, "at", and octothorpe are all language- or culture-specific. I see pretty good keyboard layout coverage though. Being language- or culture-specific is OK. In Russia, Israel, and other countries with non-roman characters, dual layout keyboards are used: you switch between the native language and U.S. -English layout. It is accepted that you need next to all symbols from it to program and everyday configuration and somesuch. http://www.cyrillicstore.com/kbd/ru-btc.gif http://www.translation.net/keyshots.html -i. |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | You can still use a different font, or make them bold, or italicized, or something. Sean "Walter" <walter@digitalmars.com> wrote in message news:bg0uo4$2nkk$3@digitaldaemon.com... > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bg02ei$1qsh$1@digitaldaemon.com... > > > > > With all those syntax highlighting text editors out there, I don't think > > > it's much of a problem setting special colours for the string to make it > > > more obvious for those with small/dense displays, no? > > > > Excellent point > > But when people write books on D, they'll be using monochrome text. Most people still use monochrome printers to print source code. |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> "Matthew Wilson" <matthew@stlsoft.org> wrote in message
> news:bg02ei$1qsh$1@digitaldaemon.com...
>
>>>With all those syntax highlighting text editors out there, I don't think
>>>it's much of a problem setting special colours for the string to make it
>>>more obvious for those with small/dense displays, no?
>>
>>Excellent point
>
>
> But when people write books on D, they'll be using monochrome text. Most
> people still use monochrome printers to print source code.
>
>
Ok, counter to counter argument coming up... :-)
But when people write books, they seem to still use visual aids of different kinds to amplify what that code means -- like a switch in font or a bold face or something. They could always do something like that. People are creative when they need to be :-). People overcome problems and that one seems to be a minor one. We just have to know if the problems outweigh the benefits.
The greatest argument against `string` to me would perhaps be the "cultural" one or the fact that it's a none-standard/unusual character.
I still vote for it, but I understand the drawbacks people see in it. I still don't think the fact that it may be hard to render on monochrome cell phones is a strong argument against it. At that point, there would be other characters that would be hard to see anyway.
Later,
John
|
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Minkov | "Ilya Minkov" <midiclub@8ung.at> wrote in message news:bg0vsn$2opm$1@digitaldaemon.com... > Legible colors use up very fast. They are simply too few. And when working in the sun, one can hardly distinguish even those. Besides, there must be someone with monochrome displays, no? Like, some people use an old 486-based Nokia organiser& cell phone, IIRC it's monochrome. While I agree that working in monochrome is an important issue (heck, *I* work in monochrome, longtime habits die really, really hard!), I just can't see anyone writing programs on their cell phone! |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | Sean L. Palmer wrote:
>>But when people write books on D, they'll be using monochrome text. Most
>>people still use monochrome printers to print source code.
Go figure out whether this tiny thing is bold, or maybe italics? Serif or Sans-Serif? It's next to impossible. Besides, there are so few usable formatting styles that they are better used for something else. Unless you want yOUR cODE tO lOOK lIKE mADMAN,S pARTY iNVITATION fLYER! :)
-i.
|
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> While I agree that working in monochrome is an important issue (heck, *I*
> work in monochrome, longtime habits die really, really hard!), I just can't
> see anyone writing programs on their cell phone!
One friend of mine tried to debug my piece of C code using it, as he was in their "summer house" in northern finnland. It was midst in winter, they had very little electricity, so this thing was the only choice. They let the generator run a couple of hours a day. But my notebook comes quite close to it in size. :) That old nokia phone is much larger than usual, and about the size of a typical old Windows CE handheld and half the length of my notebook.
-i.
|
Copyright © 1999-2021 by the D Language Foundation