syntax error

60 views
Skip to first unread message

Claude “Duke” Normandin

unread,
Dec 9, 2025, 2:46:17 AM (4 days ago) Dec 9
to Eiffel Users

`gec' chokes on the following code with:

gec person.e
Syntax error:
line 21 column 1 in person.e

The code is copied right off the above article! What's going on? TIA ...

class MAIN
^
feature
class PERSON
feature
name: STRING
age: INTEGER
set_name (new_name: STRING)
do
name := new_name
ensure
name_set: name = new_name
end
print_info
do
print ("Name: " + name + ", Age: " + age.out)
end
end
class APPLICATION
feature
main
local
p: PERSON
do
create p.set_name ("Alice")
p.age := 30
p.print_info
end
end

Eric Bezault

unread,
Dec 9, 2025, 3:41:43 AM (4 days ago) Dec 9
to eiffel...@googlegroups.com, Claude “Duke” Normandin
Only one class per file. The text of class PERSON goes to person.e
and the text of class APPLICATION goes to application.e.

When that done, the code will still not compile because it is not
void-safe. You will have to specify a creation procedure in class
PERSON. And you need a setter for `age`. And `main` needs to be
declared as creation procedure in APPLICATION. In the end you
should have that:

~~~~~~~
class PERSON

create

set_name

feature
name: STRING
age: INTEGER

set_name (new_name: STRING)
do
name := new_name
ensure
name_set: name = new_name
end

set_age (new_age: INTEGER)
require
new_age_not_negative: new_age >= 0
do
age := new_age
ensure
age_set: age = new_age
end

print_info
do
print ("Name: " + name + ", Age: " + age.out)
end
end
~~~~~~~
class APPLICATION

create

main

feature
main
local
p: PERSON
do
create p.set_name ("Alice")
p.set_age (30)
p.print_info
end
end

~~~~~~~

Then type: gec application.e

PS: It looks like the person who wrote this post on
https://programming.muthu.co has never programmed in
Eiffel. None of the examples will compile as is.
It might a good way to learn Eiffel though, trying to
fix the examples by understanding what the error
messages are complaining about.

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


On 09/12/2025 7:20, Claude “Duke” Normandin wrote:
> Reading: https://programming.muthu.co/posts/beginners-guide-to-eiffel/
> #what-is-eiffel
>
> `gec' chokes on the following code with:
>
> *gec person.e
> Syntax error:
> line 21 column 1 in person.e*
>
> The code is copied right off the above article! What's going on? TIA ...
>
> /class MAIN
> ^
> feature/
> /class PERSON
> feature
> name: STRING
> age: INTEGER
> set_name (new_name: STRING)
> do
> name := new_name
> ensure
> name_set: name = new_name
> end
> print_info
> do
> print ("Name: " + name + ", Age: " + age.out)
> end
> end
> class APPLICATION
> feature
> main
> local
> p: PERSON
> do
> create p.set_name ("Alice")
> p.age := 30
> p.print_info
> end
> end/


Ulrich Windl

unread,
Dec 9, 2025, 5:21:50 AM (4 days ago) Dec 9
to eiffel...@googlegroups.com
Hi!

Looking at the example I think it's just a complicated way to print one fixed line. The age could be a parameter of the creation procedure also.
I think the example should create at least two persons, also adding a non-trivial query, maybe "older_than(other : PERSON): BOOLEAN“. Then add some IF to the main code. Probably it will still print a constant.
The compiler I'm dreaming of would notice that, optimize the code accordingly, finally telling the user.
C compilers can do that, BTW.

Ulrich

09.12.2025 09:41:38 Eric Bezault <er...@gobosoft.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 visit https://groups.google.com/d/msgid/eiffel-users/403658ea-c9e6-450a-a0ac-efa3616356e0%40gobosoft.com.

Duke Normandin

unread,
Dec 9, 2025, 9:17:58 AM (4 days ago) Dec 9
to eiffel...@googlegroups.com
@Eric, @Ulrich

Thank you for both your replies.
I'm a little disappointed that I stumbled on am eiffel tutorial
that is so "out-to-lunch" to put it mildly. It's a bad way for
someone to start learning a new language.

Yes! Fixing the code will be a good exercise, but for day 2 of my
eiffel journey, fixing code would be hubris IMHO.

I need to see how a complete - but short - eiffel program is layed
out and why so.

I need to learn the syntax.

Is there a beginner's tutorial - NOT a PHD dissertation - to learn
ieffel with?

There is nothing at learnxinyminutes.com.
https://rosettacode.org/wiki/Category:Eiffel has a lot of code
snippets, but not a short, complete, not-too-trivial,
not-too-complex program.

Thanks again for all your input.
--
Duke

Claude “Duke” Normandin

unread,
Dec 9, 2025, 9:17:59 AM (4 days ago) Dec 9
to Eiffel Users
> The compiler I'm dreaming of would notice that, optimize the code accordingly, finally telling the user.
> C compilers can do that, BTW.

Maybe C3? or Zig or Odin? I'm test-driving those as well.

Ian Joyner

unread,
Dec 9, 2025, 7:00:11 PM (3 days ago) Dec 9
to eiffel...@googlegroups.com
Hello Duke,

Here are some old ones, first one I wrote maybe 20 years ago:

Into Eiffel.pdf
ISE Tutorial.pdf
main-custom-t-980-600x315-sqxxospfciejqkjfytssmfbdcvzbbxla.jpeg

Duke Normandin

unread,
Dec 9, 2025, 8:09:41 PM (3 days ago) Dec 9
to eiffel...@googlegroups.com
On Wed, 10 Dec 2025 10:59:36 +1100
Ian Joyner <joyne...@gmail.com> wrote:

Thank you, Ian!!

Looking forward to diving into the pdf attachments. I had a peek at
the quara posts, and as a noob to OOP as well, I'm sure that I'll
get a lot from your articles there!
--
Duke

Ulrich Windl

unread,
Dec 10, 2025, 6:12:02 AM (3 days ago) Dec 10
to 'Duke Normandin' via Eiffel Users
Hi!

I don't have it at hand right now, but there was Robert Switzers's book "Introduction to Eiffel" (AFAIR)
https://archive.org/details/eiffelintroducti0000swit
I have no idea how much this still represents current Eiffel, however.

Ulrich

09.12.2025 14:25:03 'Duke Normandin' via Eiffel Users <eiffel...@googlegroups.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 visit https://groups.google.com/d/msgid/eiffel-users/20251209062503.fc617de5804d5ff0a9039eb7%40gmx.com.

Ulrich Windl

unread,
Dec 10, 2025, 6:16:45 AM (3 days ago) Dec 10
to eiffel...@googlegroups.com
Ian,

why did you add velocity that simply returns attribute speed? I only browsed the document...

Ulrich

rfo amalasoft.com

unread,
Dec 10, 2025, 7:12:27 AM (3 days ago) Dec 10
to eiffel...@googlegroups.com
Hi Duke (et al)
This might help, or perhaps not 🙂
R

From: 'Duke Normandin' via Eiffel Users <eiffel...@googlegroups.com>
Sent: Tuesday, December 9, 2025 7:28 PM
To: eiffel...@googlegroups.com <eiffel...@googlegroups.com>
Subject: Re: [eiffel-users] syntax error
 
--
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.
Adapting_Inherited_Features_in_Eiffel.pdf

Ian Joyner

unread,
Dec 10, 2025, 7:40:35 AM (3 days ago) Dec 10
to eiffel...@googlegroups.com
I can’t remember that far back. I’m sure there are things that need revision.

Ian
> --
> 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 visit https://groups.google.com/d/msgid/eiffel-users/7c873eef-cc55-45b5-b889-b1c20e290f99%40gmail.com.

Duke Normandin

unread,
Dec 10, 2025, 2:12:56 PM (3 days ago) Dec 10
to eiffel...@googlegroups.com
On Wed, 10 Dec 2025 12:11:57 +0100 (GMT+01:00)
Ulrich Windl <u202...@gmail.com> wrote:

> I don't have it at hand right now, but there was Robert
> Switzers's book "Introduction to Eiffel" (AFAIR)
> https://archive.org/details/eiffelintroducti0000swit I have no
> idea how much this still represents current Eiffel, however.

Thx - but the book is "Limited View" - a lot of pages are missing -
for some reason. I've got enough to read at the moment anyway.
Thanks again ...

--
Duke

Duke Normandin

unread,
Dec 10, 2025, 2:12:56 PM (3 days ago) Dec 10
to eiffel...@googlegroups.com
On Wed, 10 Dec 2025 12:12:15 +0000
rfo amalasoft.com <r...@amalasoft.com> wrote:

> This might help, or perhaps not 🙂

Thx ..
--
Duke
Reply all
Reply to author
Forward
0 new messages