Once

From Liberty Eiffel Wiki
Revision as of 23:22, 13 March 2013 by Ramack (talk | contribs) (Created page with "==A definition of <TT>once</TT>== A <TT>once</TT> feature is implemented by replacing the '''do''' keyword by '''once''' e. g.: foo: INTEGER is once Result := 1 e…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A definition of once

A once feature is implemented by replacing the do keyword by once e. g.:

foo: INTEGER is
   once
     Result := 1
   end

This has the effect, that code of the feature is only executed once in the system lifetime. If the feature is a function (i. e. has a return type) every call of the feature will return the same Result, be it an expanded value or a reference. For references, the references object may change over time, but the once function will always return the identical object.

Further Aspects

  • once "manifest string"
  • once per object (other eiffel compilers have once ("OBJECT") to execute the feature body once per object) in Liberty there are no plans to implement such a feature