Closed ghost closed 4 years ago
@t0md3an
The reason why sizeof type
and sizeof(value)
are like that is because:
Take for example sizeof type
. Which operation this is would be ambiguous. Is type
a variable, or is type
a user-defined type? In order for the compiler to figure this out, it would require several lookups (which slow down compile time) and also a partially parsed tree before the main parsing takes place. This would require two separate parsers which would be hard to guarantee the same output of. Also, since Adept doesn't care about the order in which things are declared (as long as they have different names), it makes doing something like this even harder to achieve without several hacks.
Another example of this problem is sizeof *value
. Does this get the size of a pointer to type value
, or does it get the size of memory referenced by value
? Not only that, but as you have to determine whether the expression is a value or a type, it becomes exponentially more difficult and complicated, and it is just not worth it.
So in conclusion, although something like this might be nice to have, the ambiguity and technical problems that come with it are why I don't plan on implementing this in Adept 2.x.
@IsaacShelton Why complicate the use of
sizeof
? Why not combinesizeof
andsizeof value
?I think it will be better if it'll looks like: