Коллеги, интересует такой вопрос. Насколько целесообразно допускать конструкции вида:
Код:
INC(int, long);
DEC(int, long);
(* Также и: *)
INC(short, int);
DEC(short, int);
Сейчас BlackBox разрешает их, т.е. можно увеличивать/уменьшать более короткие целые путём приращения более длинных безо всяких усечений SHORT().
Аргумент "за" — видимо, упрощение описания INC/DEC в сообщении о языке:
Цитата:
INC(v, n) v, n: integer type v := v + n
v, n: любые целые. А какого размера — неважно.
Аргумент против — как-то нехорошо разрешать смешивать длинные и короткие вычисления, но с коротким результатом и без SHORT().
Я более близок ко второму варианту, т.е. запретить и указать в описании к INC/DEC, что SIZE(n) <= SIZE(v). Так строже и правильнее имхо.
Этим же вопросом я озадачил Йозефа Темпла.
Josef Templ писал(а):
It is surprising, indeed.
In BlackBox it is accepted.
In ofront it is allowed in the OfronUser.Text, i.e. in the Oberon-2 language definition.
It would be better to fix it, if possible with modest effort.
Please also look at DEC.
- Josef
Josef Templ писал(а):
> Josef, can we accept INC(int, long) ?
I don't know. In BlackBox it is allowed.
I don't know how much troubles it causes if we allow it.
May be it is even simpler to allow it than to check it.
The meaning would be that the result is silently cut off
unless there is the range check option turned on, I guess.
How is it solved in vishap?
- Josef
Josef Templ писал(а):
For compatibility reasons, I would prefer the BlackBox version.
But I have to say that also Vishap did a good job.
It is really hard to say which one to choose.
The compatibility argument could also be applied to the Vishap version, of course.
For me, however, compatibility with BlackBox seems more important.
Maybe we can find a decision by looking at possible complications in the code generator
depending on which version we choose. The BlackBox version has more
potential for complications, I guess. Look at the case INC(int, long) with and without range checks.
This should be tried out before a final decision is made.
- Josef