OberonCore
https://forum.oberoncore.ru/

INC(int, long)
https://forum.oberoncore.ru/viewtopic.php?f=127&t=6092
Страница 1 из 1

Автор:  Oleg N. Cher [ Суббота, 05 Август, 2017 12:35 ]
Заголовок сообщения:  INC(int, long)

Коллеги, интересует такой вопрос. Насколько целесообразно допускать конструкции вида:
Код:
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

Автор:  Comdiv [ Суббота, 05 Август, 2017 16:15 ]
Заголовок сообщения:  Re: INC(int, long)

Oleg N. Cher писал(а):
Насколько целесообразно
Нецелесообразно.

Автор:  Oleg N. Cher [ Понедельник, 27 Ноябрь, 2017 09:10 ]
Заголовок сообщения:  Re: INC(int, long)

Благодарю за активное обсуждение. ;-)

Если интересно, чем закончилось, то Йозеф Темпл согласился с моими доводами и сделал фикс для Ofront, который в INC(v, n)/DEC(v, n) разрешает только типы SIZE(n) <= SIZE(v).


Мне хотелось бы увидеть данное решение и в BlackBox, но вряд ли удастся убедить мэйнтейнеров всех сборок. Йозеф считает, что это неплохо, но не решает никаких практических проблем.

Автор:  Comdiv [ Понедельник, 27 Ноябрь, 2017 11:41 ]
Заголовок сообщения:  Re: INC(int, long)

Oleg N. Cher писал(а):
Йозеф считает, что это неплохо, но не решает никаких практических проблем.

При масштабном использовании решает, при микроскопическом, наверное, нет.

Автор:  Oleg N. Cher [ Четверг, 30 Ноябрь, 2017 12:43 ]
Заголовок сообщения:  Re: INC(int, long)

Josef Templ писал(а):
Oleg, in BlackBox the situation is different from ofront.
BlackBox allows too much freedom. Changing this in BlackBox would mean
to introduce an incompatibility which may affect even correct programs, that is,
programs that use INC(int, longint) but that don't overflow.
In principle, it is also possible to overflow INC(int, int) but this is also not a problem
in practice and sometimes it is the desired behavior.

To summarize: no I am not going to propose a change of INC/DEC in BlackBox,
at least not now. We are short before releasing 1.7.1.

- Josef

Страница 1 из 1 Часовой пояс: UTC + 3 часа
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/