|
Bay Six Software Beyond the Basics
|
View previous topic :: View next topic |
Author |
Message |
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Apr 7th, 2012, 6:36pm Post subject: Experiment - Metacharacters and a change |
|
|
First the change—I'm dropping the previous form of character code. The new form surrounds the character in backticks (`). What used to look like ('A') now looks like `A`.
With that out of the way, metacharacters are easy-to-read stand-ins for actual characters that would otherwise be difficult or impossible to type into a code editor. These include `CR` (carriage return, ASCII 13), `HT` (horizontal tab, ASCII 9), `LF` (line feed, ASCII 10), and possibly more.
I also added metacharacters to strings. The simplest metacharacter is the double quote which is produced by doubling it within the string literal—"""". Other metacharacters are similarly formed.
For example, to produce a string that displays as multiple lines and works on any platform: "First"NL"Second"NL"Third", where NL is short for NewLine.
You can use multiple metacharacters in a row. For example, an HTTP request might look like
The final metacharacters provide a platform-independent way of specifying file system directory separators. For example, to specify a "sounds" directory under "res" which is a subdirectory of the current directory, either of the following will work. Code: | "res"/"sounds"
"res"\"sounds" | If there are multiple separators, you must be consistent in the metacharacter you use—no mixing allowed.
What do you think? _________________ Brent |
|
Back to top |
|
|
Alyce Full Member
Joined: 04 Jul 2005 Posts: 91
|
Posted: Apr 8th, 2012, 3:22pm Post subject: Re: Experiment - Metacharacters and a change |
|
|
My $00.02.
You must still jump in and out of quote sequences. It would be easier to have the metacharacters inside the quotes, with a character signalling the metacharacter.
For instance, a backslash signals a metacharacter and must be doubled to indicate an actual backslash character.
s$ = "Hello \crlf World"
I dislike doubling quotation marks. It's already confusing enough to keep track of whether you are inside or outside the quote sequence. Doubling the quotation marks makes it even more so.
Conceptually, there is probably no difference in your method and my suggestion. It's more about ease of reading a line.
Feel free to ignore all of this, of course. Just throwin' out some thoughts, which you can also throw out. _________________ - Alyce |
|
Back to top |
|
|
STPendl Full Member
Joined: 20 Aug 2007 Posts: 161 Location: Austria
|
Posted: Apr 8th, 2012, 4:58pm Post subject: Re: Experiment - Metacharacters and a change |
|
|
I am in favor of the C-like way of using meta-characters, since they are widely spread and easy to understand.
Why create the wheel anew? _________________ Stefan
Any code I post can be freely used, just give credit. |
|
Back to top |
|
|
Brent Site Admin
Joined: 01 Jul 2005 Posts: 800
|
Posted: Apr 8th, 2012, 6:17pm Post subject: Re: Experiment - Metacharacters and a change |
|
|
Wow, I didn't even mention every MC form. I accidentally left out the hex code form; e.g. ""U+0000"" for a NUL char.
Alyce, based on your reaction, I'm guessing you would really dislike this form because it would allow something like ""U+0022"" (ASCII 34).
Admitedly, it's a complex system, but I feel it has its merits. For example, the C-like \n can be ambiguous on Windows systems whether it represents a single line-feed or a carriage-return/line-feed pair. My ""NL"" would always produce the pair of chars on Windows and line-feed on Unix-like systems.
Also, which of these examples do you all feel is easier to read?
Code: | ' #1
file$ = "res"/"sounds"/"animals"/"cow.mp3"
' #2
@if Windows
file$ = "res\\sounds\\animals\\cow.mp3"
@else
file$ = "res/sounds/animals/cow.mp3"
@endif |
_________________ Brent |
|
Back to top |
|
|
Alyce Full Member
Joined: 04 Jul 2005 Posts: 91
|
Posted: Apr 8th, 2012, 6:33pm Post subject: Re: Experiment - Metacharacters and a change |
|
|
You should probably ignore my input. Your audience (pool of users) will be quite a lot younger than I am. (Most people are!) Also, some of my preferences exist because of my vision problems.
I would have guessed that the creation of a multi-platform language was complicated, but it appears to be even more so than I imagined. _________________ - Alyce |
|
Back to top |
|
|
STPendl Full Member
Joined: 20 Aug 2007 Posts: 161 Location: Austria
|
Posted: Apr 10th, 2012, 6:57pm Post subject: Re: Experiment - Metacharacters and a change |
|
|
With XP and higher, you can already use regular slashes as the path separator, so the double-backslash is left for ancient Windows versions.
May be always use the slash for paths and the parser/compiler would change it according to the underlying O/S?
This would be like Tcl does it with its "file native" function. _________________ Stefan
Any code I post can be freely used, just give credit. |
|
Back to top |
|
|
|
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|