Simen kjaeraas <[email protected]> wrote:

bearophile <[email protected]> wrote:

Simen kjaeraas:

Not sure. This way is more explicit, and errors will be caught at
compile-time.

I see. But if a syntax is ugly and too much heavy, people (rightly) don't use it... (This is why bounded values are good as builtins).

Of course. Now, aliases help a bit here, turning that into something
like:

alias Bounded!(int, 1, 5) myInt;

myInt[] myArr;
myArr ~= myInt( 1 );


I believe using an alias would be a good idea in most such cases, as
one's bound to write Bounded!(int,1,6) in a long program, and
wonder why it doesn't compile.

Worth adding too: myInt(648492) is of course not catchable at compile
time, while such would be easy with builtin bounded integers.


--
Simen

Reply via email to