February 20, 2014 Re: $ for length? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Thursday, 20 February 2014 at 18:39:43 UTC, Kagamin wrote: > $ is meant to be a special indexing syntax (like two dots), it's not a member, not a length. Errr, what? http://dlang.org/operatoroverloading.html#Dollar |
February 20, 2014 Re: $ for length? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frustrated | On Thursday, 20 February 2014 at 18:35:26 UTC, Frustrated wrote: > it's ugly, how about ta.opLength = $ta = ta.length? Or #ta - what miniD does. See http://d.puremagic.com/issues/show_bug.cgi?id=2660 |
February 20, 2014 Re: $ for length? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stanislav Blinov | On Thursday, 20 February 2014 at 18:43:29 UTC, Stanislav Blinov wrote: > On Thursday, 20 February 2014 at 18:39:43 UTC, Kagamin wrote: > >> $ is meant to be a special indexing syntax (like two dots), it's not a member, not a length. > > Errr, what? http://dlang.org/operatoroverloading.html#Dollar It repeats what I said: > Within the arguments to array index and slicing operators Well, you can't write a.+(b) - that's a difference between syntax and member. |
February 21, 2014 Re: $ for length? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Thursday, 20 February 2014 at 18:45:49 UTC, Kagamin wrote:
> On Thursday, 20 February 2014 at 18:35:26 UTC, Frustrated wrote:
>> it's ugly, how about ta.opLength = $ta = ta.length?
>
> Or #ta - what miniD does. See http://d.puremagic.com/issues/show_bug.cgi?id=2660
Comes from Lua. It may or may not represent the number of elements in a table, since we don't want to correlate to those semantics it is probably best to stay away from it.
|
February 21, 2014 Re: $ for length? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steve Teale | On Thursday, 20 February 2014 at 10:28:43 UTC, Steve Teale wrote:
> How difficult would it be to allow the '$' to be used instead of
> length in something like:
>
> Thing[] ta;
> for (size_t i = 0; i < ta.$; i++)
>
> It can be used in slices, and indexes, so it might well be
> unambiguous here.
My first reaction is disgust, second is I'd probably get use to it, third is wondering if I would actually use it given the option (probably not).
|
Copyright © 1999-2021 by the D Language Foundation