no free functions?!

This is a discussion on no free functions?! within the Eiffel forums in Programming Languages category; So, I've learned that Eiffel doesn't have free functions or static methods. How would you go about defining, say, erf(x) ? Do you have to make it a method in some faux class? If so, does an instance of this class need to be created before the function can be called on it as if it were a method? Isn't this bizarre?...

Go Back   Application Development Forum > Programming Languages > Eiffel

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 05-14-2008, 03:56 AM
jhc0033@gmail.com
Guest
 
Default no free functions?!

So, I've learned that Eiffel doesn't have free functions or static
methods.

How would you go about defining, say, erf(x) ? Do you have to make it
a method in some faux class? If so, does an instance of this class
need to be created before the function can be called on it as if it
were a method? Isn't this bizarre?
Reply With Quote
  #2  
Old 05-14-2008, 06:53 AM
Georg Bauhaus
Guest
 
Default Re: no free functions?!

jhc0033@gmail.com schrieb:
> So, I've learned that Eiffel doesn't have free functions or static
> methods.


It does have once features.

> How would you go about defining, say, erf(x) ? Do you have to make it
> a method in some faux class? If so, does an instance of this class
> need to be created before the function can be called on it as if it
> were a method? Isn't this bizarre?


You could call it bizarre. I call it honest.
Whenever you call a function from a non-OO library,
you assume an implicit context. This context tends to
be explicit in Eiffel. E.g., the errno variable and
similar variables are connected to the funcions by
man pages only; try using them reliably in multithreaded
programs.

Eiffel forces a module around everything executable,
that is true. Does it hurt much when you write modules
featuring the empty set of state variables?

Consider Eiffel with DbC, not without it.
It might seem harder at first, because it invites you
to think about the module invariant.
However, in a stateless service class, the module invariant
should be trivial: true.
Reply With Quote
  #3  
Old 05-14-2008, 09:36 AM
Simon Willcocks
Guest
 
Default Re: no free functions?!

In message <66c2a78b-de16-4fd5-b757-7aaf90655bf4@z24g2000prf.googlegroups.com>
"jhc0033@gmail.com" <jhc0033@gmail.com> wrote:

> How would you go about defining, say, erf(x) ? Do you have to make it
> a method in some faux class? If so, does an instance of this class
> need to be created before the function can be called on it as if it
> were a method? Isn't this bizarre?


Bear in mind the instance of the library class can be expanded, so you don't
have to have an explicit create statement, just declare a local.
Reply With Quote
  #4  
Old 05-14-2008, 12:18 PM
scholz.lothar@gmail.com
Guest
 
Default Re: no free functions?!

On 14 Mai, 20:36, Simon Willcocks <simon.willco...@t-online.de> wrote:
> In message <66c2a78b-de16-4fd5-b757-7aaf90655...@z24g2000prf.googlegroups.com>
> "jhc0...@gmail.com" <jhc0...@gmail.com> wrote:
>
> > How would you go about defining, say, erf(x) ? Do you have to make it
> > a method in some faux class? If so, does an instance of this class
> > need to be created before the function can be called on it as if it
> > were a method? Isn't this bizarre?

>
> Bear in mind the instance of the library class can be expanded, so you don't
> have to have an explicit create statement, just declare a local.


Does ISE optimize this away (expanded class without member variables)
now?
They didn't in the past. I like that SmallEiffel was always better in
this way.

But i agree with the OP that i would see Eiffel go away from this pure
OO.
In my experience pure OO and multiple inheritence is just delivering
what Meyer
promised. Eiffel is used for DbC. We just added agents to get around
some of the
OO restrictions. And AFAIK there are object less constants already.
Something that
was also forbidden by Eiffel 2.0



Reply With Quote
  #5  
Old 05-15-2008, 05:00 AM
Colin LeMahieu
Guest
 
Default Re: no free functions?!

The paradigm Eiffel goes with is pure OO. A function doesn't exist
unless it operates on an ADT albeit possibly an partial ADT.

Eiffel has non-conforming inheritance which allows you to pull in
functionality in a non-conforming matter so no, you don't need to
instantiate an instance.

On May 14, 2:56 am, "jhc0...@gmail.com" <jhc0...@gmail.com> wrote:
> So, I've learned that Eiffel doesn't have free functions or static
> methods.
>
> How would you go about defining, say, erf(x) ? Do you have to make it
> a method in some faux class? If so, does an instance of this class
> need to be created before the function can be called on it as if it
> were a method? Isn't this bizarre?


Reply With Quote
  #6  
Old 05-18-2008, 08:03 AM
nicolas.edel@gmail.com
Guest
 
Default Re: no free functions?!

On 14 mai, 12:53, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> E.g., the errno variable and
> similar variables are connected to the funcions by
> man pages only; try using them reliably in multithreaded
> programs.


What's the problem with using errno reliably in multithreaded
programs ? Any decent libc implementation support that quite well
using TLS and dereference :

bits/errno.h:42:# define errno (*__errno_location ())

Reply With Quote
  #7  
Old 05-18-2008, 08:58 AM
Georg Bauhaus
Guest
 
Default Re: no free functions?!

nicolas.edel@gmail.com wrote:
> On 14 mai, 12:53, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
>> E.g., the errno variable and
>> similar variables are connected to the funcions by
>> man pages only; try using them reliably in multithreaded
>> programs.

>
> What's the problem with using errno reliably in multithreaded
> programs ? Any decent libc implementation support that quite well
> using TLS and dereference :
>
> bits/errno.h:42:# define errno (*__errno_location ())


Actually, you are proving my point: While shared variables are
not available as a C concept, TLS provides exactly the modular
setup to which I had been referring[*]; you don't see the
modularization, though. Alas, for C use, TLS is a non-portable
OS-concept, and "thread" it is not built into the language
and therefore no information for the C compiler. Eiffel,
properly implemented, has support for concurrent and parallel
programming built in via "separate" and associated semantics
(see e.g. SCOOP).

Multiprogramming looks like an old concept, and languages older
than C and cousins have typically supported multiple threads and
shared variable protection right in the language. Luckily, some of
this old wisdom will now be preserved because the multicore CPUs
provide an incentive to again become familiar with semaphores,
monitors, CSP, etc..
[*] errno is just a good example for the more general shared
variable that needs protection from concurrent access. It hadn't
always been a matter of course for a C library to be thread
safe!
Reply With Quote
  #8  
Old 05-18-2008, 04:31 PM
nicolas.edel@gmail.com
Guest
 
Default Re: no free functions?!

On 18 mai, 14:58, Georg Bauhaus <see.reply...@maps.futureapps.de>
wrote:
> nicolas.e...@gmail.com wrote:
> > On 14 mai, 12:53, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> >> E.g., the errno variable and
> >> similar variables are connected to the funcions by
> >> man pages only; try using them reliably in multithreaded
> >> programs.

>
> > What's the problem with using errno reliably in multithreaded
> > programs ? Any decent libc implementation support that quite well
> > using TLS and dereference :

>
> > bits/errno.h:42:# define errno (*__errno_location ())

>
> Actually, you are proving my point: While shared variables are
> not available as a C concept, TLS provides exactly the modular
> setup to which I had been referring[*]; you don't see the
> modularization, though. Alas, for C use, TLS is a non-portable
> OS-concept, and "thread" it is not built into the language
> and therefore no information for the C compiler.


Threads are by themselves not a C concept, just an extension (as
networking is).
Also note TLS is as non portable as "standard" libraries for Eiffel
are.

> Eiffel,
> properly implemented, has support for concurrent and parallel
> programming built in via "separate" and associated semantics
> (see e.g. SCOOP).
>


I would have say SCOOP theory is properly designed (I like it very
much as it is described in Meyer's book), but I don't believe any
implementation is provided as a *compiler* builtin but provided as
preprocessor, ie code generator (cf http://scoop.origo.ethz.ch/wiki/SCOOP_Implementation
). I had a brief look at Ecma spec and did not not see any reference
to the `separate' keyword. Any link ?

> Multiprogramming looks like an old concept, and languages older
> than C and cousins have typically supported multiple threads and
> shared variable protection right in the language. Luckily, some of
> this old wisdom will now be preserved because the multicore CPUs
> provide an incentive to again become familiar with semaphores,
> monitors, CSP, etc..


Hope you could be right but I would not bet on that. Languages such as
Erlang have been designed with concurrency in mind, have well-working
implementations but ... that's all.

>
>[*] errno is just a good example for the more general shared
> variable that needs protection from concurrent access. It hadn't
> always been a matter of course for a C library to be thread
> safe!


But now it is, so what ?! It's a pleasure to see it has been possible
to adapt current implementations to current needs without breaking the
standard API. If people making Eiffel had such good intentions for
some years, maybe I would be an happy Eiffel programmer at work.
Also note the SCOOP theory has been described in Meyer's book for a
least 10 years while been available (as a preprocessor and for 1
compiler) since only a very few time. At the same time, a lot of
things have changed in the Eiffel definition!

-Nicolas
Reply With Quote
  #9  
Old 05-19-2008, 04:22 PM
Georg Bauhaus
Guest
 
Default Re: no free functions?!

nicolas.edel@gmail.com wrote:

> Also note the SCOOP theory has been described in Meyer's book for a
> least 10 years while been available (as a preprocessor and for 1
> compiler) since only a very few time. At the same time, a lot of
> things have changed in the Eiffel definition!


Browsing the archives of c.l.eiffel discussions from
round 1990 is always instructive. There are so many
insights that will easily carpet anyone considering an
easy implementation. ;-)

One design strategy that, I speculate, might have influenced
ECMA Eiffel is the office market situation;
seems like there has been synergy of Eiffel and early .NET.
So maybe good integration with .NET and its typical support
of multithreading is a viable alternative for now.

Syntax error at line 21 in class FOO
(Concurrent Eiffel is not enabled)


end
^---------------------------
Reply With Quote
  #10  
Old 05-29-2008, 04:02 AM
Ulrich Windl
Guest
 
Default Re: no free functions?!

"jhc0033@gmail.com" <jhc0033@gmail.com> writes:

> So, I've learned that Eiffel doesn't have free functions or static
> methods.
>
> How would you go about defining, say, erf(x) ? Do you have to make it
> a method in some faux class? If so, does an instance of this class
> need to be created before the function can be called on it as if it
> were a method? Isn't this bizarre?


IMHO static members are "modules" at best, not "classes" or "objects".
If you want it object-oriented, you get it that way. Maybe you want something
else. Next one asking for "static objects" (that need no creation)?

Ulrich
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 05:53 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.