View mode: basic / threaded / horizontal-split · Log in · Help
September 12, 2007
Re: Latest const expansion
Bill Baxter Wrote:

> Yigal Chripun wrote:
> > Janice Caron wrote:
> >> On 9/11/07, Yigal Chripun <yigal100@gmail.com> wrote:
> >>> my proposal is to simply use the terms tail/head, so the syntax will be
> >>> [head|tail] const (T) | const T
> >>>
> >>> for example:
> >>> head const (C) c; // c is const but c.x isn't
> >>> tail const (C) c; // c is mutable but c.x is const
> >>> const (C) c; // as before, both c and c.x are const
> >>> head const C c; // Error
> >>> tail const C c; // Error
> >>
> >> head and tail are good variable names, so I'd rather they didn't
> >> become reserved words.
> >>
> >> But I've no problem with headconst and tailconst.
> >>
> >> Only ... would that mean we'd then also have to have a tailtailconst?
> > 
> > agreed, no need to make tail/head reserved words.
> > i thought 1 level of "tailness" is enough to cover 99% of cases...
> > can you give a use case for "tailtailconst" that can't be resolved with 
> > a combination of the const parens and tailconst?
> 
> I think tailconst is too long a word for something that will probably be 
> used pretty frequently.  If you think of C++ the most commonly used 
> const with pointer types is   "const T* foo;"  which means tail const. 
> The equivalent with a D class would be come "tailconst T foo" and you'd 
> have cases where "tailconst" appears 5 times in a function signature.
> 
>     tailconst Z some_func(tailconst A a, tailconst B b, tailconst C c, 
> tailconst D d) { ... }
> 
> Ick.
> 
> How about shortening it to just "tconst"? And there could be ttconst, 
> and tttconst as needed.  Similarly "hconst".  And still the const(T)* 
> syntax can be a synonym for tconst(T*).
> 
> Kinda reminiscent of cons, cdr, cddr, cdddr, from lisp, which really are 
> basically serving the same purpose.
> 
> --bb

You sick puppy. If I hadn't seen your many other wonderful posts I'd assume you were trolling with that one.
Keyword profilerifation is a classic language design anti-pattern.
If you must go down that route then your "const" should be parameterisable. I'm not terribly keen on that idea either.
September 12, 2007
Re: Latest const expansion
Bruce Adams wrote:
> Bill Baxter Wrote:
> 
>> Yigal Chripun wrote:
>>> Janice Caron wrote:
>>>> On 9/11/07, Yigal Chripun <yigal100@gmail.com> wrote:
>>>>> my proposal is to simply use the terms tail/head, so the syntax will be
>>>>> [head|tail] const (T) | const T
>>>>>
>>>>> for example:
>>>>> head const (C) c; // c is const but c.x isn't
>>>>> tail const (C) c; // c is mutable but c.x is const
>>>>> const (C) c; // as before, both c and c.x are const
>>>>> head const C c; // Error
>>>>> tail const C c; // Error
>>>> head and tail are good variable names, so I'd rather they didn't
>>>> become reserved words.
>>>>
>>>> But I've no problem with headconst and tailconst.
>>>>
>>>> Only ... would that mean we'd then also have to have a tailtailconst?
>>> agreed, no need to make tail/head reserved words.
>>> i thought 1 level of "tailness" is enough to cover 99% of cases...
>>> can you give a use case for "tailtailconst" that can't be resolved with 
>>> a combination of the const parens and tailconst?
>> I think tailconst is too long a word for something that will probably be 
>> used pretty frequently.  If you think of C++ the most commonly used 
>> const with pointer types is   "const T* foo;"  which means tail const. 
>> The equivalent with a D class would be come "tailconst T foo" and you'd 
>> have cases where "tailconst" appears 5 times in a function signature.
>>
>>     tailconst Z some_func(tailconst A a, tailconst B b, tailconst C c, 
>> tailconst D d) { ... }
>>
>> Ick.
>>
>> How about shortening it to just "tconst"? And there could be ttconst, 
>> and tttconst as needed.  Similarly "hconst".  And still the const(T)* 
>> syntax can be a synonym for tconst(T*).
>>
>> Kinda reminiscent of cons, cdr, cddr, cdddr, from lisp, which really are 
>> basically serving the same purpose.
>>
>> --bb
> 
> You sick puppy. If I hadn't seen your many other wonderful posts I'd assume you were trolling with that one.
> Keyword profilerifation is a classic language design anti-pattern.
> If you must go down that route then your "const" should be parameterisable. I'm not terribly keen on that idea either.

Heh.  Well I'd prefer the const*(T), const**(T) thing I posted 
previously.  But if people don't go for that I'd rather at least have 
short keywords rather than a beasts like "tailconst" and 
"tailtailconst".  :-)

--bb
Top | Discussion index | About this forum | D home