User Tools

Site Tools


eiffel:agents:simplified

Simplified notation for Agents

EiffelStudio 15.08 introduced a new syntax to simplify calls to the features taking one tuple argument. The idea is that you can drop the brackets, making the tuple implicit, without causing ambiguity. For example, with the declaration

 f (x: A; t: TUPLE [B, C]; y: D)

you can write simply

 p.f (a, b, c, d)        -- as an abbreviation for p.f (a, [b, c], d)
 p.f (a, b, c, e, d)     -- as an abbreviation for p.f (a, [b, c, e], d)

This simplification was already available in earlier versions of EiffelStudio when the tuple argument was the last one, which is particularly useful for agent calls combined with parenthesis alias notation. Instead of

 my_agent.call ([x, y, z])

you can write just

 my_agent (x, y, z)

which goes as far as possible in giving Eiffel the full syntax power of functional languages (i.e. my_agent, which describes any one of a set of possible routines, the choice being known only at run time, can be treated exactly as if it were a routine).

With 15.08 release the restriction to the last argument is gone. The mechanism is applicable as long as the routine has one tuple argument, regardless of its position.

For 15.11 release we have performed the same simplification on the type declaration side. Suppose, a class FOO is declared as

 FOO [X, T -> TUPLE, Y]

Then instead of

 x: FOO [A, TUPLE [B, C], D]
 y: FOO [A, TUPLE [B, C, E], D]

you can now write just

 x: FOO [A, B, C, D]
 y: FOO [A, B, C, E, D]

Still not convinced?

One more major change in EiffelStudio 15.11 deals with routine classes (PROCEDURE, FUNCTION) which describe agents. They involved a first parameter for the type of call target, which has turned out to be unneeded in most practical cases. That parameter has been removed. In conjunction with the previous change this means that instead of

 PROCEDURE [A, TUPLE [B, C]]
 FUNCTION [A, TUPLE [B, C], D]

you can now write

 PROCEDURE [B, C]
 FUNCTION [B, C, D]

Isn't it much clearer?

Of course, that is a breaking change. But the compiler has been engineered accordingly. You can still compile the old code. This is not an empty claim: we compiled the whole repository of EiffelStudio, including the IDE itself and a few hundred of regression test without a need to edit the source code.

On the other hand all new projects created by EiffelStudio are expected to use the new agent type declarations without the old first generic parameter.

If you are eager to try this new feature, note that:

  1. Old code is unaffected as soon as you continue using original Eiffel configuration files (ECF)
  2. New code referenced from new project ECFs will benefit from the new convention
  3. The syntax_updater utility which comes with every distribution of EiffelStudio will convert old code to use the new convention in a batch mode.
/usr/local/Eiffel_16.05/tools/spec/macosx-x86-64/bin/syntax_updater -a <directory>

Just wait a little bit before the release and enjoy the improved version of the language.

eiffel/agents/simplified.txt · Last modified: 2016/07/20 00:44 by jonathan