As per current Oberon-07 language definition, a “designator” consists of an identifier, which *may* by followed by a “selector”, which - in the case of records - consists of a dot (“.”) followed by an *identifier*, which however cannot be function call: factor = ... | designator [ActualParams] | ... designator = qualident {selector} selector = "." ident | … # <— ident here, and not factor ActualParams = "(" [ExpList] ")" It would be rather easy to extend to compiler to allow selectors to be a function call, but it simply is not part of the language definition - and for good reason. An intermediate variable always works and also makes the code more readable. -ap --------------------------------------------------------------------------------------------------------------------
There were some 'features' like that in the S3 compiler in the days I still wrote commercial Oberon code.. An intermediate variable always fixed the problem. As in your first example. -- j.
On Sat, Oct 20, 2018 at 3:52 PM <peter at easthope.ca> >wrote: > >In S3 this works.
MODULE Test; IMPORT Oberon, Texts, TextFrames, Out, Viewers; VAR nameS: Texts.Scanner; PROCEDURE Test*; VAR v: Viewers.Viewer; BEGIN v := Oberon.MarkedViewer(); Texts.OpenScanner(nameS, v.dsc(TextFrames.Frame).text, 0); Texts.Scan(nameS); Out.String("Marked viewer is named "); Out.String(nameS.s); Out.Char("."); Out.Ln END Test; BEGIN END Test.
Mark the viewer and Test.Test *
This is more succinct but gives the error "incompatible assignment". Edit.Locate leaves the caret after ().
MODULE Test IN Oberon; IMPORT Oberon, Texts, TextFrames, Out, Viewers; VAR nameS: Texts.Scanner; PROCEDURE Test*; VAR v: Viewers.Viewer; BEGIN Texts.OpenScanner(nameS, Oberon.MarkedViewer().dsc(TextFrames.Frame).text, 0); Texts.Scan(nameS); Out.String("Marked viewer is named "); Out.String(nameS.s); Out.Char("."); Out.Ln END Test; BEGIN END Test.
In the Oberon subsystem of A2, the preceeding compiles with no error. Anything interesting to learn from that?
The (TextFrames.Frame) type cast seems a little devious. Can the result be accomplished without a type cast?
Thanks, ... Lyall E.
participants (1)
-
Andreas Pirklbauer