🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.eiffel
Article #1511

Re: Parameter Specification

#1511
From: Bertrand Meyer
Date: Thu, 11 Jan 1990 02:30
45 lines
2219 bytes
From <19453@watdragon.waterloo.edu> by djana@watdragon.waterloo.edu:

> Is there any way to pass parameters to a function by name, by value in Eiffel
> or does it use call by reference only? 


	There are two kinds of values in Eiffel: references and objects.
An entity declared of class type denotes a reference; an entity declared
of expanded type denotes an object.

For example:

	a: LINKED_QUEUE [X] 	-- Reference (class type)
	s: STRING				-- Reference (STRING is a class of the
										basic library)
	s: expanded POINT		-- Object (expanded type)
	n: INTEGER				-- Object (expanded type)

As the last example indicates, the basic types INTEGER, REAL, DOUBLE,
CHARACTER and BOOLEAN are treated as expanded class types.

All argument passing is done by value: the actual argument is
(conceptually) copied into the formal argument). What is copied is
the reference (for a class type) or the object (for an expanded type).

From a practical perspective, however, a reference is not interesting
in itself; what is interesting is the object it refers to (the official
terminology is that a reference IS ATTACHED TO an object). Then
if you consider the object of interest in both the expanded type and
the class type cases, what you get is essentially

	- Passing by reference for formal arguments of class type.

	- Passing by value for formal arguments of expanded type.

Note that the mode is determined by the target (the formal argument).
This makes it possible to have very convenient transformations between
references and objects. The transformations are purely conceptual
and do not cost any computation time.


For details, please see the book ``Eiffel: The Language''.
-- 
-- Bertrand Meyer
bertrand@eiffel.com
Technical Details
Message-ID: <219@eiffel.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!ucsd!hub!eiffel!bertrand
References: <19453@watdragon.waterloo.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!ucsd!hub!eiffel!bertrand
From: bertrand@eiffel.UUCP (Bertrand Meyer)
Newsgroups: comp.lang.eiffel
Subject: Re: Parameter Specification
Summary: Value or reference
Keywords: Eiffel
Message-ID: <219@eiffel.UUCP>
Date: 11 Jan 90 02:30:53 GMT
References: <19453@watdragon.waterloo.edu>
Distribution: comp
Organization: Interactive Software Engineering, Santa Barbara CA
Lines: 45