March 10, 2005 Re: The new | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | "Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:d0odfv$sor$1@digitaldaemon.com... >> That may be so, but that's a piss poor rationale for a criticism. Were it as black and white as that, then ignorance of regex would be the thing to address. It's not exactly a useless skill to have ... > > To tell the truth, I've never even seen regular expressions before I came across D, and I haven't exactly lived under a rock. It seems like anyone who uses a Posix-based OS has knowledge of them, and I'm not sure why, as I've personally never used Linux or the like. > >> Ok, that's opinion. Gotcha. Now, how about some substantiation? > > Sorry, I have nothing to prove. Don't be so childish. It's not a question of having something to prove, or at least not in the way you mean. If you want people to diligently read your posts when they contain unsubstantiated opinion, you're living in a dream world. Any people who are interested in such are *far* more likely to watch Fox News. |
March 10, 2005 Re: The new | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | Catching up on "old" threads... could be irrelevant by now. >> I agree. Using an identifier is something people recognize and can understand. Seeing $ will confuse people and think there is more magic in there than there is. When I see $ used for this (or even when I imagine $length, $arguments, etc) I can't relate it to any other C-like language construct that I know. > >Hmm. That actually gets a big "So what?". I mean, seeing char[], aa declaration syntax, opThis and opThat, are all foreign/unfamiliar. The syntax is based on very familiar C constructs and people can guess the semantics of what is going on. Using $ in expressions gives no clue about semantics. I agree $length would be better than $ but why invent a wacky syntax that will cause C programmer to think D has left Kansas and landed in Oz? I'd prefer to reserve "wacky" syntax for advanced concepts (like the !() for template instantiation and such) and let bread-and-butter D code look like bread-and-butter C/Java/C++ code. >To me it seems not the slightest bizarre. But then I am a big fan of Ruby, which has such things by the bucketload. that's fine. To me it reminds me of shell scripting variable expansion. To some it means Basic strings. >> It actually looks to me like a preprocessor hook of some kind or shell-like environment variable expansion. > >Is that a bad thing? I think the opposite. If we adopt this $xyz thing - i.e. we can find significant use, and it can have good unambiguous semantics - then the distinctness of it is precisely what's required. True - though I suppose it boils down to what is considered significant. I think there was a post about waiting on this whole thing until more uses can be found (or something like that). |
March 10, 2005 Re: Another way | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | > BTW, there's a subtlety here that has been largely overlooked. Suppose one > creates a class that overloads [] and wants to look like an array? What's $ > then? For length, it was simple. The 'this' pointer for the class reference > is added to the scope on the opening [, and removed on the closing ]. Then, > if the class declares a 'length' property, that length will be found and > used. > > Of course, I can bash the compiler to make $ look up a classes' length > property, too, but that just strikes me as uuugly. Well, I agree that $ with classes is odd, but $length to me isn't. It's like a reserved word and can be defined as "the .length of whatever the enclosing [] refers to". > Maybe we're just going at this all wrong. I really like length as the > implicitly declared array length, for the reason it is straightforward and > it just looks visually appealing in use. Having it be __length is ugly, and > $length isn't much better. Both of the latter would also require the > this.length lookup hack. Well, I'd say that $length is better than length, because it behaves differently than any other identifier (afaik, length is the only one with special treatment), so it should also look unlike other identifiers.. Same goes for _arguments vs. $args -- it is special in that it refers to the "..." and is not explicitly declared anywhere, so it should also look special. IMHO, of course.. > Maybe the right answer is to just make it illegal to declare a local > variable with the name 'length'. Fields, functions, etc., could still be > named 'length'. It's still a bit of a hack, but language design is rarely > free of that stuff. To me that's just too inconsistent - for all other possible identifiers, you can either use them everywhere or nowhere (if reserved). Having length be special is just odd, even more so, because I guess it would be forbidden as a local var even in functions that don't even use [length]. I can just see the hundreds of posts this would produce :) xs0 |
March 10, 2005 Re: The new | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | On Thu, 10 Mar 2005 07:33:46 +1100, Kris <Kris_member@pathlink.com> wrote: [snip] >> >> Weird I know, but Walter has chosen. > > > FWIW; what Walter has done is a compromise over what is sometimes called > "end-point paranoia" ~ most often witnessed in graphics libs, but relevant here > also (google that phrase to find some QuickDraw links). > > When writing the Mango HTTP server, I don't recall one time where I had to > compensate for such things; and there's a whole lot of slicing going on in there > :-) > > I know it seems a bit wacky that part of slicing is 'n' and another part is > 'n-1', but I've found it to work well in practice. > I realize that Walter's choice has been done for very good and sound reasons, mainly I think to do with performance. It's just that I'm also used to working with Euphoria and that uses a 1-based indexing scheme. That is the first item is 1, the second item is 2, etc... and the last item is $. Slices in Euphoria are inclusive. array[$] is the last item. array[1..$] is the first item to the last item inclusively. No big deal. -- Derek -- Derek |
March 10, 2005 Re: The new | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | On Thu, 10 Mar 2005 07:37:51 +1100, Jarrett Billingsley <kb3ctd2@yahoo.com> wrote: >> I think the use of '$' can be traced back to regular expressions, > > Of course, to someone who has no idea what regex syntax even is, it just > seems stupid. Especially coming from a BASIC background, in which $ is the > "string variable" suffix. > >> It *does* take some getting used to though. > > I really hate how length has been deprecated. I really don't like the $ one > bit. > > I love the $. It's like coming home again. It reads well because it is something I'm used to and comfortable with using. It seems natural to me. -- Derek |
March 10, 2005 Re: The new | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | Matthew wrote:
> "Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:d0odfv$sor$1@digitaldaemon.com...
>
>>>That may be so, but that's a piss poor rationale for a criticism. Were it as black and white as that, then ignorance of regex would be the thing to address. It's not exactly a useless skill to have ...
>>
>>To tell the truth, I've never even seen regular expressions before I came across D, and I haven't exactly lived under a rock. It seems like anyone who uses a Posix-based OS has knowledge of them, and I'm not sure why, as I've personally never used Linux or the like.
>>
>>
>>>Ok, that's opinion. Gotcha. Now, how about some substantiation?
>>
>>Sorry, I have nothing to prove.
>
>
> Don't be so childish. It's not a question of having something to prove, or at least not in the way you mean.
>
> If you want people to diligently read your posts when they contain unsubstantiated opinion, you're living in a dream world. Any people who are interested in such are *far* more likely to watch Fox News.
>
>
>
Whatever your political leanings, please make the distinction between Fox _News_ and Fox. Fox News is quite good, as reflected in its current ratings surge. The rest of the media is 'Rather' biased, imo.
|
March 10, 2005 Re: The new "$" has an inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to David L. Davis | David L. Davis wrote: > The "$" appears to have an inconsistent behavior as seen in the test program > below, and it really should be nailed down before anyone uses it in their D > programs…once of course, it's approved that it will be used to stand for > array.length when it's between the array brackets ([ $ ]). So, should "$" stand > for "length - 1" or "length?" Myself I'd like for it to stand for "length - 1," > because it saves me some extra typing by removing the need for "- 1." Redefining it this way means that you'd have to use array[2..$+1] to slice from element 2 to the end of an array. Seems somewhat sillier than using $-1 to refer to the final element'll ever look. And as for the fencepost errors.... > Tho I still think using the "$" for this is still a waste of a good symbol which > could be put to better use on something else. If it's approved by the group, > then I will use it a lot!! :) > > # // test2.d > # private import std.stdio; > # # int main() > # { > # char[] sTest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; > # > # // Here "$" does "length - 1" > # writefln( "\"" ~ sTest[ 0 .. $ ] ~ "\"" ); <snip> So the output is "ABCDEFGHIJKLMNOPQRSTUVWXY" ? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
March 10, 2005 Re: The new '$' has an inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | In article <d0pggr$238v$1@digitaldaemon.com>, Stewart Gordon says... > >David L. Davis wrote: >> The "$" appears to have an inconsistent behavior as seen in the test program below, and it really should be nailed down before anyone uses it in their D programs…once of course, it's approved that it will be used to stand for array.length when it's between the array brackets ([ $ ]). So, should "$" stand for "length - 1" or "length?" Myself I'd like for it to stand for "length - 1," because it saves me some extra typing by removing the need for "- 1." > >Redefining it this way means that you'd have to use > > array[2..$+1] > >to slice from element 2 to the end of an array. Seems somewhat sillier than using $-1 to refer to the final element'll ever look. And as for the fencepost errors.... > >> Tho I still think using the "$" for this is still a waste of a good symbol which could be put to better use on something else. If it's approved by the group, then I will use it a lot!! :) >> >> # // test2.d >> # private import std.stdio; >> # >> # int main() >> # { >> # char[] sTest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; >> # >> # // Here "$" does "length - 1" >> # writefln( "\"" ~ sTest[ 0 .. $ ] ~ "\"" ); ><snip> > >So the output is > >"ABCDEFGHIJKLMNOPQRSTUVWXY" > >? > >Stewart. > >-- >My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. Stewart I don't which version you're using, but I'm using the Windows version of dmd v0.116, and below is the results I get...which seems to be different from your test. # // test2b.d # private import std.stdio; # # int main() # { # char[] sTest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; # # // Here $ does .length - 1 # writefln( "\"" ~ sTest[ 0 .. $ ] ~ "\"" ); # writefln( "\"" ~ sTest[ 0 .. sTest.length ] ~ "\"" ); # # return 0; # } Output: C:\dmd>bin\dmd test2b.d C:\dmd\bin\..\..\dm\bin\link.exe test2b,,,user32+kernel32/noi; C:\dmd>test2b "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" C:\dmd> David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" |
March 10, 2005 Re: The new '$' has an inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to David L. Davis | David L. Davis wrote: <snip> > Stewart I don't which version you're using, but I'm using the Windows version of > dmd v0.116, and below is the results I get...which seems to be different from > your test. What test? I was merely restating what you were telling me it does. > # // test2b.d > # private import std.stdio; > # # int main() > # { > # char[] sTest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; > # > # // Here $ does .length - 1 > # writefln( "\"" ~ sTest[ 0 .. $ ] ~ "\"" ); # writefln( "\"" ~ sTest[ 0 .. sTest.length ] ~ "\"" ); > # > # return 0; > # } > > Output: > C:\dmd>bin\dmd test2b.d > C:\dmd\bin\..\..\dm\bin\link.exe test2b,,,user32+kernel32/noi; > > C:\dmd>test2b > "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > "ABCDEFGHIJKLMNOPQRSTUVWXYZ" That is correct behaviour. And your comment just above the writefln statements is inconsistent with it. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
March 10, 2005 Re: The new '$' has an inconsistent behavior | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | In article <d0potn$2c1c$1@digitaldaemon.com>, Stewart Gordon says... > >David L. Davis wrote: ><snip> >> Stewart I don't which version you're using, but I'm using the Windows version of dmd v0.116, and below is the results I get...which seems to be different from your test. > >What test? I was merely restating what you were telling me it does. > >> # // test2b.d >> # private import std.stdio; >> # >> # int main() >> # { >> # char[] sTest = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; >> # >> # // Here $ does .length - 1 >> # writefln( "\"" ~ sTest[ 0 .. $ ] ~ "\"" ); >> # writefln( "\"" ~ sTest[ 0 .. sTest.length ] ~ "\"" ); >> # >> # return 0; >> # } >> >> Output: >> C:\dmd>bin\dmd test2b.d >> C:\dmd\bin\..\..\dm\bin\link.exe test2b,,,user32+kernel32/noi; >> >> C:\dmd>test2b >> "ABCDEFGHIJKLMNOPQRSTUVWXYZ" >> "ABCDEFGHIJKLMNOPQRSTUVWXYZ" > >That is correct behaviour. And your comment just above the writefln statements is inconsistent with it. > >Stewart. > >-- >My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. Ok. I see where you’re coming from now. In that comment above the first writefln() I was pointing out that [0 .. $] and [0 .. $ - 1] are giving the exact same results, which is, it displays the whole string (array of characters) value. So with that in mind, the statement above the writefln() was not inconsistent with the results, but in appearance they look very inconsistent. Please do not be offended if you already know the following. But someone here on the forum pointed out to me, that this is the way D deals with the length when it’s doing array slicing. In other words sTest.length equals 26 which is based on 1 starting in the first position. Where as slicing [0..sTest.length] is based on zero starting in the first position, thus in this special case with a little D magic (hack)… both “sTest.length” and “sTest.length – 1” end up displaying same result. Anyway, thanks for your comments. David L. ------------------------------------------------------------------- "Dare to reach for the Stars...Dare to Dream, Build, and Achieve!" |
Copyright © 1999-2021 by the D Language Foundation