Jump to page: 1 27  
Page
Thread overview
$ instead of length
Mar 02, 2005
Walter
Mar 02, 2005
Ben Hinkle
Mar 02, 2005
Georg Wrede
Mar 02, 2005
bamb00
Mar 02, 2005
Walter
Mar 03, 2005
U.Baumanis
Mar 03, 2005
Walter
Mar 03, 2005
Dave
Mar 03, 2005
Matthew
Mar 04, 2005
Ben Hinkle
Mar 04, 2005
Matthias Becker
Mar 02, 2005
Derek Parnell
Mar 02, 2005
Georg Wrede
Mar 02, 2005
Norbert Nemec
Mar 02, 2005
brad
Mar 02, 2005
SeeSchloss
Mar 02, 2005
brad
Mar 02, 2005
Walter
Mar 04, 2005
Matthias Becker
Mar 04, 2005
John Reimer
Mar 04, 2005
John Reimer
Mar 02, 2005
Derek Parnell
Mar 03, 2005
Andrew Fedoniouk
Mar 03, 2005
Derek Parnell
Mar 03, 2005
Georg Wrede
Mar 02, 2005
Ben Hinkle
Mar 02, 2005
Walter
Mar 02, 2005
Regan Heath
Mar 02, 2005
Walter
Mar 05, 2005
Manfred Nowak
Mar 08, 2005
Walter
Mar 02, 2005
cahoots
Mar 02, 2005
SeeSchloss
Mar 03, 2005
cahoots
Mar 03, 2005
Martin M. Pedersen
Mar 03, 2005
brad beveridge
Mar 04, 2005
Walter
Mar 02, 2005
Lynn Allan
Mar 03, 2005
Ben Hinkle
Mar 03, 2005
Walter
Mar 03, 2005
Lionello Lunesu
Mar 03, 2005
xs0
Mar 03, 2005
cahoots
Mar 03, 2005
pragma
Mar 03, 2005
Nick Sabalausky
Mar 03, 2005
Ben Hinkle
Mar 03, 2005
John Reimer
Mar 03, 2005
Regan Heath
Mar 03, 2005
John Reimer
Mar 03, 2005
John Reimer
Mar 03, 2005
Derek Parnell
Mar 03, 2005
John Reimer
Mar 03, 2005
Regan Heath
Mar 03, 2005
John Reimer
Re: $ instead of length (~OT)
Another try: "len" instead of length
Mar 05, 2005
Norbert Nemec
Mar 06, 2005
Matthew
Mar 07, 2005
Regan Heath
Mar 07, 2005
Derek Parnell
March 02, 2005
[Starting a new thread on this, because the original is old and wandered off topic too far]

"Derek Parnell" <derek@psych.ward> wrote in message news:cu90r1$1e7t$1@digitaldaemon.com...
> Agreed. I have always supported the use of a symbol rather than an English word to represent the array's length property. I'm keen to promote the readibilty of source code by humans, so an extra 'dot' seems counter productive to that aim.


The $ idea for the length is a good one. The reason I didn't adopt it was because I am trying to save $ for something big. I have a lot of thoughts (inspired by some emails from Andrei A.) that $ could be very, very useful in a future metaprogramming feature. Using $ as a length is a minor use, too minor for such an important symbol!

So the options are:

1) Make it illegal for length within [ ] to hide another length in an outer scope. This would essentially preclude length being used as a global, or even as a class member.

2) Same as (1), but only restrict it if length is a variable local to a
function.

3) Make length a keyword. This is not that much different from (1).

4) Change length to another identifier. Nothing stands out as being obviously right.

5) Invent a token for it that is other than '$'.


March 02, 2005
Walter wrote:

> 4) Change length to another identifier. Nothing stands out as being
> obviously right.

How about _length ? (Similar to the already used _arguments)

--anders
March 02, 2005
"Anders F Björklund" <afb@algonet.se> wrote in message news:d052rf$gbm$1@digitaldaemon.com...
> Walter wrote:
>
>> 4) Change length to another identifier. Nothing stands out as being obviously right.
>
> How about _length ? (Similar to the already used _arguments)
>
> --anders

I like that. Some pluses and minuses:
+ indicates the identifier is special (prevents people from looking for a
non-existant variable called "length")
+ precendent for using _identifier (as you mention)
+ is greppable
- looks uglier than length
- _length is more likely to be used in regular code than _arguments and
_argptr

Given that it isn't *that* much uglier I think the pluses outweight the minuses.


March 02, 2005

Walter wrote:
> [Starting a new thread on this, because the original is old and wandered off
> topic too far]
> 
> "Derek Parnell" <derek@psych.ward> wrote in message
> news:cu90r1$1e7t$1@digitaldaemon.com...
> 
>>Agreed. I have always supported the use of a symbol rather than an English
>>word to represent the array's length property. I'm keen to promote the
>>readibilty of source code by humans, so an extra 'dot' seems counter
>>productive to that aim.
> 
> 
> 
> The $ idea for the length is a good one. The reason I didn't adopt it was
> because I am trying to save $ for something big. I have a lot of thoughts
> (inspired by some emails from Andrei A.) that $ could be very, very useful
> in a future metaprogramming feature. Using $ as a length is a minor use, too
> minor for such an important symbol!
> 
> So the options are:
> 
> 1) Make it illegal for length within [ ] to hide another length in an outer
> scope. This would essentially preclude length being used as a global, or
> even as a class member.
> 
> 2) Same as (1), but only restrict it if length is a variable local to a
> function.
> 
> 3) Make length a keyword. This is not that much different from (1).
> 
> 4) Change length to another identifier. Nothing stands out as being
> obviously right.
> 
> 5) Invent a token for it that is other than '$'.

Using a single-character token for length has worked well in Euphoria, where Rob incorporated it recently. The code gets a lot more readable, terse, and tends to decrease errors.

I agree that one should not obstruct the way for Serious improvements to the laguage with frivolous introductions of minor things.

Is there any single character other than $ that we could use?

....

A throw-in-the-air idea, what if we used minus ("-")?
March 02, 2005
Im totally for this , so speciying an offest from the end of an array would look like


mySlice[0 .. -5];

I remember the argument against this being that its legal C to use a negative offest for an array .  I can't imagine any noble purpose for it in C/C++ , and I think it works perfect for the length property in D so lets rally round the minus!

Charlie


"Georg Wrede" <georg.wrede@nospam.org> wrote in message news:42261AE9.2080708@nospam.org...
>
>
> Walter wrote:
> > [Starting a new thread on this, because the original is old and wandered
off
> > topic too far]
> >
> > "Derek Parnell" <derek@psych.ward> wrote in message news:cu90r1$1e7t$1@digitaldaemon.com...
> >
> >>Agreed. I have always supported the use of a symbol rather than an
English
> >>word to represent the array's length property. I'm keen to promote the readibilty of source code by humans, so an extra 'dot' seems counter productive to that aim.
> >
> >
> >
> > The $ idea for the length is a good one. The reason I didn't adopt it
was
> > because I am trying to save $ for something big. I have a lot of
thoughts
> > (inspired by some emails from Andrei A.) that $ could be very, very
useful
> > in a future metaprogramming feature. Using $ as a length is a minor use,
too
> > minor for such an important symbol!
> >
> > So the options are:
> >
> > 1) Make it illegal for length within [ ] to hide another length in an
outer
> > scope. This would essentially preclude length being used as a global, or even as a class member.
> >
> > 2) Same as (1), but only restrict it if length is a variable local to a
> > function.
> >
> > 3) Make length a keyword. This is not that much different from (1).
> >
> > 4) Change length to another identifier. Nothing stands out as being obviously right.
> >
> > 5) Invent a token for it that is other than '$'.
>
> Using a single-character token for length has worked well in Euphoria, where Rob incorporated it recently. The code gets a lot more readable, terse, and tends to decrease errors.
>
> I agree that one should not obstruct the way for Serious improvements to the laguage with frivolous introductions of minor things.
>
> Is there any single character other than $ that we could use?
>
> ....
>
> A throw-in-the-air idea, what if we used minus ("-")?


March 02, 2005
On Wed, 2 Mar 2005 10:55:31 -0800, Walter wrote:

> [Starting a new thread on this, because the original is old and wandered off topic too far]
> 
> "Derek Parnell" <derek@psych.ward> wrote in message news:cu90r1$1e7t$1@digitaldaemon.com...
>> Agreed. I have always supported the use of a symbol rather than an English word to represent the array's length property. I'm keen to promote the readibilty of source code by humans, so an extra 'dot' seems counter productive to that aim.
> 
> 
> The $ idea for the length is a good one. The reason I didn't adopt it was because I am trying to save $ for something big. I have a lot of thoughts (inspired by some emails from Andrei A.) that $ could be very, very useful in a future metaprogramming feature. Using $ as a length is a minor use, too minor for such an important symbol!
> 
> So the options are:
> 
> 1) Make it illegal for length within [ ] to hide another length in an outer scope. This would essentially preclude length being used as a global, or even as a class member.
> 
> 2) Same as (1), but only restrict it if length is a variable local to a
> function.
> 
> 3) Make length a keyword. This is not that much different from (1).
> 
> 4) Change length to another identifier. Nothing stands out as being obviously right.
> 
> 5) Invent a token for it that is other than '$'.

I'm still in the '$' camp. Since that symbol was introduced in Euphoria for this exact purpose, it has become an instant success and has literally changed the way one thinks about coding things. Using a word to do the same is always going to clash with something, sometime.

-- 
Derek Parnell
Melbourne, Australia
http://www.dsource.org/projects/build
3/03/2005 7:22:15 AM
March 02, 2005
Walter wrote:
> [Starting a new thread on this, because the original is old and wandered off
> topic too far]
> 
> "Derek Parnell" <derek@psych.ward> wrote in message
> news:cu90r1$1e7t$1@digitaldaemon.com...
> 
>>Agreed. I have always supported the use of a symbol rather than an English
>>word to represent the array's length property. I'm keen to promote the
>>readibilty of source code by humans, so an extra 'dot' seems counter
>>productive to that aim.
> 
> 
> 
> The $ idea for the length is a good one. The reason I didn't adopt it was
> because I am trying to save $ for something big. I have a lot of thoughts
> (inspired by some emails from Andrei A.) that $ could be very, very useful
> in a future metaprogramming feature. Using $ as a length is a minor use, too
> minor for such an important symbol!
> 
> So the options are:
> 
> 1) Make it illegal for length within [ ] to hide another length in an outer
> scope. This would essentially preclude length being used as a global, or
> even as a class member.
> 
> 2) Same as (1), but only restrict it if length is a variable local to a
> function.
> 
> 3) Make length a keyword. This is not that much different from (1).
> 
> 4) Change length to another identifier. Nothing stands out as being
> obviously right.
> 
> 5) Invent a token for it that is other than '$'.
> 
> 

I think the only other ASCII symbol left not used in D is @, but it looks kinda weird for length. Of course, Unicode is very vast...

_______________________
Carlos Santander Bernal
March 02, 2005
How about changing the identifier to 'len'?
* Easy to read
* Pretty intuitive to understand
* I can't think of anything to mix it up with
* used by other languages already (e.g. Python)
* MUCH EASIER TO TYPE (Ever found yourself typeing "lenght"?)

Question still is, how to handle it. The cleanest idea that I can come with is to really make it a keyword. If you leave it an identifier, it needs some special handling that makes the language more complex. One more keyword does not hurt anyone. If it breaks any code, it will not do it silently.

My proposal would be to leave the property of arrays called "length". Inside index espressions, it gives the length of the corresponding dimension. (has to be worked out more clearly for ND-arrays) Anywhere else it mich still serve as prefix operator, allowing to write 'len(myarray)' (or even 'len myarray') instead of myarray.length

Greetings,
Norbert



Walter schrieb:
> [Starting a new thread on this, because the original is old and wandered off
> topic too far]
> 
> "Derek Parnell" <derek@psych.ward> wrote in message
> news:cu90r1$1e7t$1@digitaldaemon.com...
> 
>>Agreed. I have always supported the use of a symbol rather than an English
>>word to represent the array's length property. I'm keen to promote the
>>readibilty of source code by humans, so an extra 'dot' seems counter
>>productive to that aim.
> 
> 
> 
> The $ idea for the length is a good one. The reason I didn't adopt it was
> because I am trying to save $ for something big. I have a lot of thoughts
> (inspired by some emails from Andrei A.) that $ could be very, very useful
> in a future metaprogramming feature. Using $ as a length is a minor use, too
> minor for such an important symbol!
> 
> So the options are:
> 
> 1) Make it illegal for length within [ ] to hide another length in an outer
> scope. This would essentially preclude length being used as a global, or
> even as a class member.
> 
> 2) Same as (1), but only restrict it if length is a variable local to a
> function.
> 
> 3) Make length a keyword. This is not that much different from (1).
> 
> 4) Change length to another identifier. Nothing stands out as being
> obviously right.

How about 'len'?
* Easy to read
* Pretty intuitive to understand
* I can't think of anything to mix it up with
* used by other languages already (e.g. Python)
* MUCH EASIER TO TYPE (Ever found yourself typeing "lenght"?)
March 02, 2005
"Georg Wrede" <georg.wrede@nospam.org> wrote in message news:42261AE9.2080708@nospam.org...
> A throw-in-the-air idea, what if we used minus ("-")?

Because then array[length - 1] becomes array[- - 1].

 :-(


March 02, 2005

Carlos Santander B. wrote:
> Walter wrote:
> 
>> [Starting a new thread on this, because the original is old and wandered off
>> topic too far]
>>
>> "Derek Parnell" <derek@psych.ward> wrote in message
>> news:cu90r1$1e7t$1@digitaldaemon.com...
>>
>>> Agreed. I have always supported the use of a symbol rather than an English
>>> word to represent the array's length property. I'm keen to promote the
>>> readibilty of source code by humans, so an extra 'dot' seems counter
>>> productive to that aim.
>>
>>
>>
>>
>> The $ idea for the length is a good one. The reason I didn't adopt it was
>> because I am trying to save $ for something big. I have a lot of thoughts
>> (inspired by some emails from Andrei A.) that $ could be very, very useful
>> in a future metaprogramming feature. Using $ as a length is a minor use, too
>> minor for such an important symbol!
>>
>> So the options are:
>>
>> 1) Make it illegal for length within [ ] to hide another length in an outer
>> scope. This would essentially preclude length being used as a global, or
>> even as a class member.
>>
>> 2) Same as (1), but only restrict it if length is a variable local to a
>> function.
>>
>> 3) Make length a keyword. This is not that much different from (1).
>>
>> 4) Change length to another identifier. Nothing stands out as being
>> obviously right.
>>
>> 5) Invent a token for it that is other than '$'.
>>
>>
> 
> I think the only other ASCII symbol left not used in D is @, but it looks kinda weird for length. Of course, Unicode is very vast...

Shi-, er, baloney! That _does_ rise specters about us running up the creek with context independent lexing! What's gonna happen in two years?

That kind of suggests #3?
« First   ‹ Prev
1 2 3 4 5 6 7