July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | `string` "Walter" <walter@digitalmars.com> wrote in message news:bfvihp$19sq$1@digitaldaemon.com... > That's what I'm trying to find! > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bfv9m8$118q$1@digitaldaemon.com... > > LOL. What isn't? :) > > > > "Walter" <walter@digitalmars.com> wrote in message news:bfv2s8$ql4$1@digitaldaemon.com... > > > > > > "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bfv0or$oeh$2@digitaldaemon.com... > > > > Here's an unpopular thought: why not use @"string" and be consistent > > with > > > > C#? Easier on the brain even if it doffs one's cap to M$ > > > > > > It's aesthetically unpleasing. > > > > > > > > > > > > |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | > That will work. But an empty string would be """""". Hmm. How about
Yeah, but as there is absolutely no point in using the WYSIWYG syntax for empty strings, I doubt this will have any practical problems :)
-fg
|
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | `string` seems good. It doesn't really matter to me. I'm fine with the way it is now, too. "Walter" <walter@digitalmars.com> wrote in message news:bfu9kp$3f1$1@digitaldaemon.com... > 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). > > So, I've been thinking of going back to the C way and having ' ' for character literals. That means that wysiwyg strings are left without a lexical syntax. Any ideas for something that would look nice? How about using back quotes ` `, or is that just too hard to distinguish in certain fonts? One thing to keep in mind is that wysiwyg strings are not going to be > used with nearly the same frequency as escaped strings, so the syntax can be > a bit less convenient for them. > > I'd like to use /string/, but that leads to too may lexical ambiguities. > > Some possibilities are: > 1) prefixing the " with a letter or a character, as in: > W"string" > %"string" > !"string" > 2) using a character not used in C, such as: > `string` > $string$ > @string@ > #string# > > |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vathix | > 'string' : wysiwyg strings
> "string" : escaped strings
Should be as they are I think.
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.
Roald
|
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | 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). 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. Likewise with preferring a function which takes a single character argument over a function which takes a string. > So, I've been thinking of going back to the C way and having ' ' for > character literals. That means that wysiwyg strings are left without a > lexical syntax. Any ideas for something that would look nice? How about > using back quotes ` `, or is that just too hard to distinguish in certain > fonts? One thing to keep in mind is that wysiwyg strings are not going to be > used with nearly the same frequency as escaped strings, so the syntax can be > a bit less convenient for them. Just a note. The "`" character is not a back quote, it's a grave accent. Like the tilde and circumflex accent (the caret), it was apparently originally intended as a character modifier, although I can't find any history on computer keyboard layout. That's why it looks nothing like a quote character, and more like the window system has made a rendering error. 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'd like to use /string/, but that leads to too may lexical ambiguities. > > Some possibilities are: > 1) prefixing the " with a letter or a character, as in: > W"string" > %"string" > !"string" > 2) using a character not used in C, such as: > `string` > $string$ > @string@ > #string# Dollar, "at", and octothorpe are all language- or culture-specific. I see pretty good keyboard layout coverage though. |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> escreveu na mensagem news:bfu9kp$3f1$1@digitaldaemon.com... > 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). > > So, I've been thinking of going back to the C way and having ' ' for character literals. That means that wysiwyg strings are left without a lexical syntax. Any ideas for something that would look nice? How about using back quotes ` `, or is that just too hard to distinguish in certain fonts? One thing to keep in mind is that wysiwyg strings are not going to be > used with nearly the same frequency as escaped strings, so the syntax can be > a bit less convenient for them. > > I'd like to use /string/, but that leads to too may lexical ambiguities. > > Some possibilities are: > 1) prefixing the " with a letter or a character, as in: > W"string" > %"string" > !"string" > 2) using a character not used in C, such as: > `string` > $string$ > @string@ > #string# Hi, Couldn't we use a symbol for character literals, like other languages, like #a or $a for the letter "a"? It would probably be simpler, and we could keep '' and "" for strings. Also \ would be character literals, instead of single character strings. Best regards, Daniel Yokomiso. "Whenever I climb I am followed by a dog called 'Ego'." - Friedrich Nietzsche (1844-1900) --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.502 / Virus Database: 300 - Release Date: 18/7/2003 |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Fabian Giesen | "Fabian Giesen" <rygNO@SPAMgmx.net> wrote in message news:bg05b6$1tnm$1@digitaldaemon.com... > > That will work. But an empty string would be """""". Hmm. How about > > Yeah, but as there is absolutely no point in using the WYSIWYG syntax for empty strings, I doubt this will have any practical problems :) You do have a point. |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | "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 Matthew Wilson | "Matthew Wilson" <matthew@stlsoft.org> wrote in message news:bg02ej$1qsh$2@digitaldaemon.com... > `string` The three frontrunners are at the moment: `string` """string""" r"string" |
July 27, 2003 Re: String literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> "Russ Lewis" <spamhole-2001-07-16@deming-os.org> wrote in message
> news:bfuc2b$5ck$1@digitaldaemon.com...
>
>>What about double double quotes for wysiwyg?
>>
>>""string"" : wysiwyg string
>>
>>I don't really like that syntax, but I think it's better than any of the
>>other alternatives proposed so far. I like the fact that it uses a
>>quote character to denote a string, rather than some other, arbitrarily
>>selected character.
>
>
> It's a good idea, but it conflicts with using "" to denote an empty string.
> I thought of using "'string'", but it looks too weird <g>.
>
>
Python uses r"string" for raw (wysiwyg) strings.
C# uses @"string". This is probably easier to parse, as @ isn't used anywhere else in the language. (as far as I know)
|
Copyright © 1999-2021 by the D Language Foundation