Jump to page: 1 27  
Page
Thread overview
yalp (yet another length proposal)
Mar 10, 2005
Ben Hinkle
Mar 10, 2005
Andrew Fedoniouk
Mar 10, 2005
Matthew
Mar 11, 2005
J C Calvarese
Mar 11, 2005
Derek Parnell
Mar 11, 2005
Ben Hinkle
Mar 11, 2005
Ben Hinkle
Mar 14, 2005
Walter
Mar 14, 2005
Vathix
Mar 14, 2005
Derek Parnell
Mar 14, 2005
Derek Parnell
Mar 14, 2005
Derek Parnell
Mar 14, 2005
Derek Parnell
Mar 11, 2005
John Reimer
Mar 11, 2005
John Reimer
Mar 11, 2005
Derek Parnell
Mar 11, 2005
John Reimer
$; shall we declare "Time, gentlemen." ? [WAS Re: yalp (yet another length proposal)]
Mar 11, 2005
Matthew
Re: $; shall we declare
Mar 11, 2005
Jon Andrew
Re: $; shall we declare time?
Mar 11, 2005
Kris
Mar 14, 2005
xs0
Re: $; shall we declare time?
Mar 11, 2005
Kris
Mar 11, 2005
Derek Parnell
Mar 11, 2005
Lars Ivar Igesund
Mar 11, 2005
Matthew
Mar 11, 2005
Derek Parnell
Mar 11, 2005
Kris
Mar 13, 2005
Regan Heath
Mar 12, 2005
clayasaurus
Mar 12, 2005
Les Baker
Mar 12, 2005
John Demme
$ as prefix (and $len vs, $length)
Mar 13, 2005
Norbert Nemec
Mar 13, 2005
kris
Mar 14, 2005
J C Calvarese
Mar 14, 2005
Walter
Mar 14, 2005
J C Calvarese
Mar 14, 2005
John Demme
Mar 14, 2005
J C Calvarese
Mar 14, 2005
Derek Parnell
Mar 14, 2005
Ben Hinkle
Mar 14, 2005
Derek Parnell
Mar 14, 2005
Kris
Mar 14, 2005
Ben Hinkle
Mar 14, 2005
Charles
Mar 14, 2005
Kris
Mar 14, 2005
Sean Kelly
Mar 14, 2005
Kris
Mar 14, 2005
Kris
Mar 15, 2005
Kris
Mar 14, 2005
Sean Kelly
Mar 14, 2005
Kris
Mar 11, 2005
Derek Parnell
Mar 12, 2005
Norbert Nemec
March 10, 2005
I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _

./std/format.d: putstr(tmpbuf[n .. _]);
./std/math2.d: real result = coefficients[_ - 1];
./std/math2.d: if (s[_ - 1] == 'h')
./std/path.d:     return fullname[i .. _];
./std/path.d: return fullname[i .. _];
./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
./std/path.d: fullname = fullname[0 .. _ - existing.length] ~ ext;
./std/path.d:    return d.length < path.length && path[d.length] == sep[0];
./std/path.d:  else if (p1[_ - 1] == '\\')
./std/path.d:      p = p1 ~ p2[1 .. _];
./std/path.d:     else if (p1[_ - 1] == '\\')
./std/path.d: else if (p1[_ - 1] == sep[0])
./std/path.d:   if (fnmatch(name[j .. _], pattern[pi + 1 .. _]))
./std/regexp.d: result ~= string[p .. _];
[snip many more examples from phobos]


March 10, 2005
Aesthetically, I like this more than $ :).



"Ben Hinkle" <bhinkle@mathworks.com> wrote in message news:d0q91g$2toq$1@digitaldaemon.com...
>I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _
>
> ./std/format.d: putstr(tmpbuf[n .. _]);
> ./std/math2.d: real result = coefficients[_ - 1];
> ./std/math2.d: if (s[_ - 1] == 'h')
> ./std/path.d:     return fullname[i .. _];
> ./std/path.d: return fullname[i .. _];
> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
> ./std/path.d: fullname = fullname[0 .. _ - existing.length] ~ ext;
> ./std/path.d:    return d.length < path.length && path[d.length] ==
> sep[0];
> ./std/path.d:  else if (p1[_ - 1] == '\\')
> ./std/path.d:      p = p1 ~ p2[1 .. _];
> ./std/path.d:     else if (p1[_ - 1] == '\\')
> ./std/path.d: else if (p1[_ - 1] == sep[0])
> ./std/path.d:   if (fnmatch(name[j .. _], pattern[pi + 1 .. _]))
> ./std/regexp.d: result ~= string[p .. _];
> [snip many more examples from phobos]
> 


March 10, 2005
My only qualm is that it's too hard to see.

But I'd be happy to give this a test, a la $, if _ became a reserved identifier. (Shouldn't be too much of an imposition, since who's going to want to use that anyway, other than Dobfuscators?)

(Don't you love this new try-it-and-see stuff? <g>)

The other advantage is that it saves $ for the future: TMP and all that ..

"Ben Hinkle" <bhinkle@mathworks.com> wrote in message news:d0q91g$2toq$1@digitaldaemon.com...
>I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _
>
> ./std/format.d: putstr(tmpbuf[n .. _]);
> ./std/math2.d: real result = coefficients[_ - 1];
> ./std/math2.d: if (s[_ - 1] == 'h')
> ./std/path.d:     return fullname[i .. _];
> ./std/path.d: return fullname[i .. _];
> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
> ./std/path.d: fullname = fullname[0 .. _ - existing.length] ~ ext;
> ./std/path.d:    return d.length < path.length && path[d.length] ==
> sep[0];
> ./std/path.d:  else if (p1[_ - 1] == '\\')
> ./std/path.d:      p = p1 ~ p2[1 .. _];
> ./std/path.d:     else if (p1[_ - 1] == '\\')
> ./std/path.d: else if (p1[_ - 1] == sep[0])
> ./std/path.d:   if (fnmatch(name[j .. _], pattern[pi + 1 .. _]))
> ./std/regexp.d: result ~= string[p .. _];
> [snip many more examples from phobos]
>



March 11, 2005
Ben Hinkle wrote:
> I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _
> 
> ./std/format.d: putstr(tmpbuf[n .. _]);
> ./std/math2.d: real result = coefficients[_ - 1];

I like it. It's clever.

If someone wants to use _ as an actual identifier, they should be shot anyway (IMO). It should be used for something special.


-- 
Justin (a/k/a jcc7)
http://jcc_7.tripod.com/d/
March 11, 2005
Ben Hinkle wrote:
> I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _
> 
> ./std/format.d: putstr(tmpbuf[n .. _]);
> ./std/math2.d: real result = coefficients[_ - 1];
> ./std/math2.d: if (s[_ - 1] == 'h')
> ./std/path.d:     return fullname[i .. _];
> ./std/path.d: return fullname[i .. _];
> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
> ./std/path.d: fullname = fullname[0 .. _ - existing.length] ~ ext;
> ./std/path.d:    return d.length < path.length && path[d.length] == sep[0];
> ./std/path.d:  else if (p1[_ - 1] == '\\')
> ./std/path.d:      p = p1 ~ p2[1 .. _];
> ./std/path.d:     else if (p1[_ - 1] == '\\')
> ./std/path.d: else if (p1[_ - 1] == sep[0])
> ./std/path.d:   if (fnmatch(name[j .. _], pattern[pi + 1 .. _]))
> ./std/regexp.d: result ~= string[p .. _];
> [snip many more examples from phobos] 
> 
> 

Of all the alternatives, this ones seems to be a better choice.  It's definitely not perfect, but perfect is hard to come by.

And many thanks to Walter for being so willing to experiment recently. I was absolutely shocked to see the changes in the last dmd release.  It sure is nice to have things "try-before-you-buy!"

_JJR_
March 11, 2005
John Reimer wrote:
> Ben Hinkle wrote:
> 
>> I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _
>>
>> ./std/format.d: putstr(tmpbuf[n .. _]);
>> ./std/math2.d: real result = coefficients[_ - 1];
>> ./std/math2.d: if (s[_ - 1] == 'h')
>> ./std/path.d:     return fullname[i .. _];
>> ./std/path.d: return fullname[i .. _];
>> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
>> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
>> ./std/path.d: fullname = fullname[0 .. _ - existing.length] ~ ext;
>> ./std/path.d:    return d.length < path.length && path[d.length] == sep[0];
>> ./std/path.d:  else if (p1[_ - 1] == '\\')
>> ./std/path.d:      p = p1 ~ p2[1 .. _];
>> ./std/path.d:     else if (p1[_ - 1] == '\\')
>> ./std/path.d: else if (p1[_ - 1] == sep[0])
>> ./std/path.d:   if (fnmatch(name[j .. _], pattern[pi + 1 .. _]))
>> ./std/regexp.d: result ~= string[p .. _];
>> [snip many more examples from phobos]
>>
> 
> Of all the alternatives, this ones seems to be a better choice.  It's definitely not perfect, but perfect is hard to come by.

Grammar correction: "Of all the alternatives, this one seems to be the best choice." :-P

-JJR
March 11, 2005
On Thu, 10 Mar 2005 23:03:58 -0600, J C Calvarese wrote:

> Ben Hinkle wrote:
>> I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _
>> 
>> ./std/format.d: putstr(tmpbuf[n .. _]);
>> ./std/math2.d: real result = coefficients[_ - 1];
> 
> I like it. It's clever.
>
It is significantly more difficult to see. Not every one has 20-y.o. eyes any more? ;-)

> If someone wants to use _ as an actual identifier, they should be shot anyway (IMO).

Yep, a pretty silly identifier name. But why? Because maybe its hard to see?

> It should be used for something special.

What *is* this "something special" that I keep reading about?

-- 
Derek Parnell
Melbourne, Australia
11/03/2005 11:03:15 PM
March 11, 2005
On Thu, 10 Mar 2005 22:35:49 -0800, John Reimer wrote:

> John Reimer wrote:
>> Ben Hinkle wrote:
>> 
>>> I don't know if this has been already proposed but I was pondering the "negative index" and the "missing index" proposals and it occurred to me that a place-holder that would be (a) an identifier, (b) unobtrusive and (c) unlikely to be used by a real coder is an underscore. I grepped phobos for some examples of a[a.length] and replaced them with a[_] to get a feel for how it would look. At one point Walter proposed making it an error to have the "magic length identifier" shadow a symbol with the same name - and I think that would catch any yahoo who actually wants to have symbols named _
>>>
>>> ./std/format.d: putstr(tmpbuf[n .. _]);
>>> ./std/math2.d: real result = coefficients[_ - 1];
>>> ./std/math2.d: if (s[_ - 1] == 'h')
>>> ./std/path.d:     return fullname[i .. _];
>>> ./std/path.d: return fullname[i .. _];
>>> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
>>> ./std/path.d: if (fullname.length && fullname[_ - 1] == '.')
>>> ./std/path.d: fullname = fullname[0 .. _ - existing.length] ~ ext;
>>> ./std/path.d:    return d.length < path.length && path[d.length] ==
>>> sep[0];
>>> ./std/path.d:  else if (p1[_ - 1] == '\\')
>>> ./std/path.d:      p = p1 ~ p2[1 .. _];
>>> ./std/path.d:     else if (p1[_ - 1] == '\\')
>>> ./std/path.d: else if (p1[_ - 1] == sep[0])
>>> ./std/path.d:   if (fnmatch(name[j .. _], pattern[pi + 1 .. _]))
>>> ./std/regexp.d: result ~= string[p .. _];
>>> [snip many more examples from phobos]
>>>
>> 
>> Of all the alternatives, this ones seems to be a better choice.  It's definitely not perfect, but perfect is hard to come by.
> 
> Grammar correction: "Of all the alternatives, this one seems to be the best choice." :-P

No it doesn't ;-)

-- 
Derek Parnell
Melbourne, Australia
11/03/2005 11:09:16 PM
March 11, 2005
"Derek Parnell" <derek@psych.ward> wrote in message news:onv6vwm3agbo$.1ezjtrb8uag1.dlg@40tude.net...
> On Thu, 10 Mar 2005 23:03:58 -0600, J C Calvarese wrote:
>
>> Ben Hinkle wrote:
>>> I don't know if this has been already proposed but I was pondering the
>>> "negative index" and the "missing index" proposals and it occurred to me
>>> that a place-holder that would be (a) an identifier, (b) unobtrusive and
>>> (c)
>>> unlikely to be used by a real coder is an underscore. I grepped phobos
>>> for
>>> some examples of a[a.length] and replaced them with a[_] to get a feel
>>> for
>>> how it would look. At one point Walter proposed making it an error to
>>> have
>>> the "magic length identifier" shadow a symbol with the same name - and I
>>> think that would catch any yahoo who actually wants to have symbols
>>> named _
>>>
>>> ./std/format.d: putstr(tmpbuf[n .. _]);
>>> ./std/math2.d: real result = coefficients[_ - 1];
>>
>> I like it. It's clever.
>>
> It is significantly more difficult to see. Not every one has 20-y.o. eyes any more? ;-)

When surrounded by spaces it should be easier to pick out, but I agree visibility is the biggest drawback.

>> If someone wants to use _ as an actual identifier, they should be shot
>> anyway (IMO).
>
> Yep, a pretty silly identifier name. But why? Because maybe its hard to see?

More because it has no meaning. The only usage of _ as an identifier that I could find was a declaration in some C++ code in recls for an unused field of a struct. I didn't try to figure out the context too much but it looked like the struct was some OS struct with some padding in it. The only uses for _ that I can imagine outside of that is for code obfuscation contests.

>> It should be used for something special.
>
> What *is* this "something special" that I keep reading about?

I was also pretty sceptical about the usefulness of $/length/whatever. Then I started grepping around to write a post about how silly the feature is and I realized it is more common than I thought. It seemed like about 1/3 to 1/2 of indexing expressions would involve the length. So I started to think it would be useful after all.

-Ben


March 11, 2005
Derek Parnell wrote:

>>>Of all the alternatives, this ones seems to be a better choice.  It's definitely not perfect, but perfect is hard to come by.
>>
>>Grammar correction: "Of all the alternatives, this one seems to be the best choice." :-P
> 
> 
> No it doesn't ;-) 
> 

Ha! :-)
« First   ‹ Prev
1 2 3 4 5 6 7