a:=b in dot notation?
Author Message
a:=b in dot notation?

Hi,

I already know that "a < b < c" is equivalent to
"a.binary_less(b.binary_less(c)).

How do I write the expression "a:=b" in dot form?

Jost

Sun, 31 Oct 1999 03:00:00 GMT
a:=b in dot notation?

Quote:

> I already know that "a < b < c" is equivalent to
> "a.binary_less(b.binary_less(c)).

Nope, the equivalent is a.binary_less(b).binary_less(c), if the feature
infix "<" also has the name binary_less in your classes.

Quote:
> How do I write the expression "a:=b" in dot form?

If "a" is a reference, you can't use dot form. For expanded "a", it is

a.copy(b)

Cheers,

Fridtjof.

Sun, 31 Oct 1999 03:00:00 GMT
a:=b in dot notation?

:= operator is used at the reference level: after a:=b both a and b
reference the same object (if variables are not expanded).
dot notation is at the instance level. I think  we can say : the  sended
message is interpreted by the referenced instance.

I dont know if the semantic could allow what you are asking for.
May be you are speaking about .clone or .deep_clone (and =, .is_equal,
.is_deep_equal)?

Richard

--
------------------------------------------------------------------
Richard Mouli   Tel: +32 2 724 17 37 (19 80)
Sony Telecom Europe (n.v.) Fax: + 32 2 726 26 86

B-1130 Brussels
------------------------------------------------------------------

Sun, 31 Oct 1999 03:00:00 GMT
a:=b in dot notation?

Quote:
> How do I write the expression "a:=b" in dot form?

If a is expanded (INTEGER for instance), "a.copy(b)". If a is a reference,
there is no equivalent, and there cannot be, because a := b changes the
object the dot notation refers to.

Sun, 31 Oct 1999 03:00:00 GMT
a:=b in dot notation?

Quote:

> I already know that "a < b < c" is equivalent to
> "a.binary_less(b.binary_less(c)).

Eiffel does not actually have a feature 'binary_less', although
this fictional name is used in ETL p380 to explain how to test
the validity of an infix expression. But in this case, "a < b < c"
would be equivalent to (a.binary_less(b)).binary_less(c) because
of left-to-right evaluation of "<".

[Aside: "(a < b)" evaluates to a BOOLEAN value "true" or "false".
Because BOOLEAN does not descend from COMPARABLE, it is meaningless
to ask whether it is less than 'c' (even if 'c' is BOOLEAN).]

Quote:
> How do I write the expression "a:=b" in dot form?

In general, you can't. A dot-form routine call can modify an object
referenced by an entity ('a' in your example) but it can't attach
a different object to that entity.

Depending what you want to do, you might find that

a.copy(b)

does what you want. It copies the attributes of the object referenced
by 'b' into the corresponding attributes of the object referenced by
'a', but doesn't change which object 'a' references.

If you want a dot-form of assignment, you should look at the Sather
language which is similar to Eiffel in some ways and does offer this
notation - see comp.lang.sather

Regards,
Roger
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.eiffel.demon.co.uk/ | +44-1772-687525

Sun, 31 Oct 1999 03:00:00 GMT
a:=b in dot notation?

Quote:

>> How do I write the expression "a:=b" in dot form?

> If a is expanded (INTEGER for instance), "a.copy(b)". If a is a reference,
> there is no equivalent, and there cannot be, because a := b changes the
> object the dot notation refers to.

Thanks a lot. I just don't understand, what ":=" really is; is it a
"procedure" that can operate on all objects or a "routine" of the class
that "a" belongs to?

I don't know what "expanded" means at the moment, but do you think it would
be possible to overcome the limitation you described by introducing features
that are commom to all objects of a certain class?

Jost
P.S.: Yes, I picked that example from ETL page 380 :). I am quite new to Eiffel
and trying to understand the concepts that Eiffel inroduces.

Mon, 01 Nov 1999 03:00:00 GMT
a:=b in dot notation?

Quote:
Jost Boekemeier writes:

> >> How do I write the expression "a:=b" in dot form?

> > If a is expanded (INTEGER for instance), "a.copy(b)". If a is a reference,
> > there is no equivalent, and there cannot be, because a := b changes the
> > object the dot notation refers to.

> ... I just don't understand, what ":=" really is; is it a
> "procedure" that can operate on all objects or a "routine" of the class
> that "a" belongs to?

Except when the left-hand-side is "expanded", it's neither. It doesn't
"operate" on any object, so shouldn't be expressed as a routine. What it does
is to change which object is referred to by the entity ("name") on its
left-hand-side.

Quote:
> I don't know what "expanded" means at the moment...

"Expanded" means that an entity represents a value rather than a reference
to a standalone object. When 'a' is expanded, "a := b" can be rewritten
"a.copy(b)" because no reference is changing.

Quote:
> ... but do you think it would
> be possible to overcome the limitation you described by introducing features
> that are commom to all objects of a certain class?

I don't see what the "limitation" is (because I don't mind writing ":=" for
assignment), but in any case you can have a feature common to all objects of
a certain class (and its descendants). Constant attributes already have this
property, and you can use the "once" keyword to do the same for objects.
For example, feature "s" in the following code is a shared STRING that is
automatically initialized whenever it is first used:

s: STRING is
once
!!result.make(0)
end

Regards,
Roger
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.eiffel.demon.co.uk/ | +44-1772-687525

Mon, 01 Nov 1999 03:00:00 GMT
a:=b in dot notation?

Quote:

> Not sure whether this was what you were after but, if a and b are attributes
> of a class,

>   a := b

> can also be written as

>   Current.a := Current.b

Not in Eiffel. Although the expression "a" has the same value as the
expression "current.a", "current.a" is just that - an expression - and as such
cannot appear on the left hand side of an assignment instruction.

Regards,
Roger
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.eiffel.demon.co.uk/ | +44-1772-687525

Tue, 02 Nov 1999 03:00:00 GMT
a:=b in dot notation?

Quote:

> I already know that "a < b < c" is equivalent to
> "a.binary_less(b.binary_less(c)).

> How do I write the expression "a:=b" in dot form?

Althought ":=" looks like just another operator, it is fundamentally
different. Think of the usual meaning of "a.f(...)":

Invoke the feature f(...) on the object to which a refers.

To take an example of an operator (different syntax), "a + b":

Invoke the feature "+ b" on the object to which a refers
(b is also evaluated first, of course)

Now, look at the semantics of "a := b"

Cause a to refer to a new object, namely, the one referenced
by b.

You might say it is an operation on the identifier, instead of on the
object. Thus, there is no "assign(x)" feature that is equivalent
to ":= x".

Jim Heliotis

Tue, 02 Nov 1999 03:00:00 GMT
a:=b in dot notation?

:P.S.: Yes, I picked that example from ETL page 380 :). I am quite new to Eiffel
:      and trying to understand the concepts that Eiffel inroduces.

I also got acquainted with Eiffel through ETL. While I think it's a great book,
you may find it a bit heavy on language rules and light on examples. You may
find OOSC2 a better starting point if you want a book from Bertrand Meyer.
Or, if you want something simpler and clearer, try Jean-Marc Jezequel's book.

Regards,
Don.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Tue, 02 Nov 1999 03:00:00 GMT
a:=b in dot notation?

:>> How do I write the expression "a:=b" in dot form?

Not sure whether this was what you were after but, if a and b are attributes
of a class,

a := b

can also be written as

Current.a := Current.b

:... I just don't understand, what ":=" really is;

It's just the assignment operator and the semantics depends on the nature
(reference vs. expanded (value) ) of the source and target entities (variables).

See ETL, Chapter 20 - "Reattaching Entities". (In particular, the table on
P. 317.)

:I don't know what "expanded" means at the moment..

An expanded entity is one that represents a value (ie. an actual object) rather
than a reference to an object. For example,

We have,

expanded class INTEGER ...

a: INTEGER
b: INTEGER
...
a := b

'a' and 'b' are expanded entities and and the assignment results in the source
*value* (say 5) being copied to the target entity.

However,

class B ... end

p: B
q: B
...
p := q

'p' and 'q' are reference entities and assignment results in the source
*reference* being copied to the target entity.

Don.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Tue, 02 Nov 1999 03:00:00 GMT

 Page 1 of 1 [ 11 post ]

Relevant Pages