Symbolic forms of loops

72 views
Skip to first unread message

Alexander Kogtenkov

unread,
Mar 17, 2020, 8:19:06 AM3/17/20
to Eiffel Users
Adoption of Unicode in Eiffel goes on. Some messages in this mailing list mentioned one such change: symbolic forms of loops. They can make code more concise and closer to traditional math. Assertions can benefit from this improvement, in particular. My blog post at the link below provides some examples of the new syntax and its relation to the keyword-based one:
 
 
Happy Eiffeling,
Alexander Kogtenkov

Thomas Beale

unread,
Apr 1, 2020, 5:40:55 PM4/1/20
to Eiffel Users
Hi Alex,

I was just contemplating this:
c: s ¦ print (c.name)

Why not just use the initial symbol, and forget the final one, i.e.
c: s ¦ print (c.name)

That seems more consistent with the other operators.

- thomas

Eric Bezault

unread,
Apr 1, 2020, 6:56:57 PM4/1/20
to eiffel...@googlegroups.com, Thomas Beale
On 01/04/2020 23:40, Thomas Beale wrote:
> Hi Alex,
>
> I was just contemplating this:
> |⟳c:s ¦print (c.name)⟲|
>
> Why not just use the initial symbol, and forget the final one, i.e.
> |⟳c:s ¦print (c.name)|
>
> That seems more consistent with the other operators.

This could only work if we restrict this notation to only
one instruction. So the following:

⟳ c: s ¦ print (c.name); print ("%N")

would be a loop followed by an instruction to print a newline
(and not a loop with two instructions).

Personally, this would have my preference. I think that I already
suggested something along these lines to ISE. After all, the
symbolic form of loops is already at subset of what could be
expressed with the `across` form (e.g. no loop variant and
invariants). So this restriction on the number of instructions
should not be so much of a problem: if one wants more, just
use the `across` form.

--
Eric Bezault
mailto:er...@gobosoft.com
http://www.gobosoft.com

Thomas Beale

unread,
Apr 2, 2020, 12:35:32 PM4/2/20
to Eiffel Users
Eric,
I agree with all of that.
- thomas

Larry Rix

unread,
Apr 20, 2020, 3:10:00 PM4/20/20
to Eiffel Users
Is this in the following version? If so, I am unable to compile it (I get a syntax error).

Installation information:
Version = EiffelStudio 19.12 (19.12.10.3819 Community Edition - win64)
Monitor DPI = 96

$ISE_EIFFEL = C:\Program Files\Eiffel Software\EiffelStudio 19.12 GPL
$ISE_LIBRARY = C:\Program Files\Eiffel Software\EiffelStudio 19.12 GPL
$ISE_PLATFORM = win64
$ISE_C_COMPILER = msc_vc140

Alexander Kogtenkov

unread,
Apr 21, 2020, 10:50:21 AM4/21/20
to eiffel...@googlegroups.com
Dear Larry,
 
I’ve tried the following code with EiffelStudio 19.12.10.3768 and it prints TrueFalse
 
            a: ARRAY [INTEGER]
        do
            a := <<3, 5, 7>>
            print (∀ x: a ¦ x > 2)
            print (∃ x: a ¦ x = 2)
 
Is it the same for you?
 
(It looks like the download page lists a slightly higher version, I can test with it as well, but I guess, it should produce the same result.)
 
Regards,
Alexander Kogtenkov
 
 
Понедельник, 20 апреля 2020, 22:10 +03:00 от Larry Rix <lar...@moonshotsoftware.com>:
 
--
You received this message because you are subscribed to the Google Groups "Eiffel Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/eiffel-users/5990ed8a-4d74-4c27-a874-98e33658b924%40googlegroups.com.
 

Larry Rix

unread,
Apr 24, 2020, 2:50:29 PM4/24/20
to Eiffel Users
Hi Alex,

I copied your code over and it ran with no issues.

So, now I am wondering what I am doing wrong.

Larry Rix

unread,
Apr 24, 2020, 2:57:43 PM4/24/20
to Eiffel Users
I have the following:

output: REAL_64
--
local
l_sum: REAL_64
do
⟳ ic: inputs ¦ l_sum := l_sum + (ic.value * ic.weight) ⟲
across
inputs as ic
from
l_sum := 0.0
loop
l_sum := l_sum + (ic.item.value * ic.item.weight)
end
Result := 1 / (1 + exp (- l_sum - bias))
end


Which produces a syntax error:

Rule Description Location Position Severity
1 Syntax Error Syntax error at line 47. AI_SIGMOID_NEURON (elotto) 47, 62
Syntax error at line 47 in class AI_SIGMOID_NEURON

        do
            ⟳ ic: inputs ¦ l_sum := l_sum + (ic.value * ic.weight) ⟲
----------------------------------------------------------------------^
            across



Alexander Kogtenkov

unread,
Apr 24, 2020, 3:06:26 PM4/24/20
to eiffel...@googlegroups.com
There is some issue with the parser. The current workaround could be adding a semicolon after the instruction in the loop:
 
   ⟳ ic: inputs ¦ l_sum := l_sum + (ic.value * ic.weight); ⟲
 
We’ll take a look what’s wrong. Thanks for noticing it.
 
Regards,
Alexander Kogtenkov
 
 
Larry Rix <lar...@moonshotsoftware.com>:

Eric Bezault

unread,
Apr 24, 2020, 5:48:24 PM4/24/20
to eiffel...@googlegroups.com
FYI, this code compiles and works fine with the Gobo compiler.
So it should be fixable: the issue is not in the grammar
but in its implementation in EiffelStudio's parser.
> 1Syntax ErrorSyntax error at line 47.AI_SIGMOID_NEURON (elotto)47, 62
Reply all
Reply to author
Forward
0 new messages