the best language I have ever met(?)

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 23 11:15:52 PST 2016


On Wednesday, November 23, 2016 18:58:55 ketmar via Digitalmars-d-learn 
wrote:
> On Wednesday, 23 November 2016 at 18:54:35 UTC, Igor Shirkalin
>
> wrote:
> > On Tuesday, 22 November 2016 at 00:08:05 UTC, ketmar wrote:
> >> On Monday, 21 November 2016 at 23:49:27 UTC, burjui wrote:
> >>> Though I would argue that it's better to use '_' instead of
> >>> '$' to denote deduced fixed size, it seems more obvious to me:
> >>>
> >>> int[_] array = [ 1, 2, 3 ];
> >>
> >> alas, `_` is valid identifier, so `enum _ = 42; int[_] a;` is
> >> perfectly valid. dollar is simply most logical non-identifier
> >> character.
> >
> > We can define static array without counting the elements as
> > following:
> >
> >
> > enum array_ = [1u,2,3,4];
> > uint[array_.length] static_array = array_;
>
> there are workarounds, of course. yet i'll take mine `uint[$] a =
> [1u,2,3,4];` over that quoted mess at any time, without second
> thought. ;-)

It's nice, but it's non-standard. So, it seems to me that using it is just
going to lead to problems like you ran into in this thread where you posted
an example that wasn't valid D, and it'll make you that much more annoyed
when you have to write code that _is_ standard D and can't use your
enhancements. So, I really think that it would be better if you just used
standard D, but obviously, that's up to you.

We really should add a helper for this to std.typecons though. Maybe I'll
try and do something for it this holidy weekend...

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list