Title: Language Modernization ideas for discussion - Idea 4 - Richer operators Post by: Eric B. on January 25, 2021, 11:42:21 pm Next idea: Richer set of operators. Adds support for the following operators: +=, -=, *=, /=, and IN.
For instance: Code is the same as Code This could be used with any of the normal math operators (+=, -=, *=, etc.). IN is a shortened form of OR: Code is the same as Code
Title: Re: Language Modernization ideas for discussion - Idea 4 - Richer operators Post by: Reuben B. on January 26, 2021, 04:01:28 am IN has also been discussed previously, https://4js.com/support/issue/?id=FGL-4238
I have never really understood why we have not implemented an IN(), after all it is SQL syntax that most 4gl developers are familiar with. I would place BETWEEN, MIN, MAX in the same category as being available in SQL but not 4gl. Over time we have added syntax from SQL such as nvl() and iif(), and who used to code sin(x) as SELECT SIN(x) FROM systables WHERE tabid = 1 before util.Math was added. I am sure there are 4gl developers that have coded something they would code in SQL statement into a 4gl statement and been caught out. A number of customers will have their own library functions that implement a list (many possible implementations such as delimited string, XML, JSON, DICTIONARY, ARRAY) and then have functions to create a list and to search within it. For example Code I would have coded as Code ... the only downside being I was limited to however many listN functions I coded to construct a list with N elements unless I built my list one element at a time. What is missing is a compelling argument to get IN over the line. Your example is probably not the best ... Code could be written as Code or Code
A better example is to say Code
as to code it like ... Code ... sees expr() evaluated multiple times and val1(), val2() and val3() always evaluated (unless OPTIONS SHORT CIRCUIT is turned on) To code it so each expression is only evaluated once is something like ... Code
and being able to code Code and Code is preferable So if you have a better example, that will help the cause. Reuben Title: Re: Language Modernization ideas for discussion - Idea 4 - Richer operators Post by: Rene S. on January 28, 2021, 03:26:24 pm Implementing operators like += should not be a big deal. Those operators are very common.
The operator IN is another story. Yes, this operator could be helpful, the operator exists in SQL for good reasons. But. See Reuben's example using the operator IN in a CASE statement: Code
This this the simplified grammar of the CASE statement: Code
When parsing Code Then the compiler would not see the operator IN, the compiler would seen the function name IN. Compare this with Code
All I want to say is: the operator IN does not solve the request for enhancing the CASE statement to support more than one value per WHEN. (Edited to transpose CASE and WHEN which had been typed the wrong way around) |