plasma icon indicating copy to clipboard operation
plasma copied to clipboard

Object-method notation

Open PaulBone opened this issue 5 years ago • 0 comments

OO languages allow the syntax:

object.method()

To invoke a method call, and this is based around field/property access (.). Functional languages, and Plasma so far don't have this. But it's useful for guiding editor features like intelisense and also makes chaining of calls easy without additional syntax.

Plasma will use . for field access anyway, including lookups in an environment. But mostly values won't setup functions that operate on them as methods, since they won't be fields. If we do this it'll have to be defined in terms of environment access. My initial thoughts where to either let a list type say what methods it has (and how to pass itself as an argument) or to allow each method to say what "objects" it can be called on. I remember about a week ago I had an even better idea (maybe it was some syntax) but I can't remember it. Maybe it also had to do with modules since the List module is likely to contain a List type, both would refer to the map function.

Anyway, I think this could be good, but it'll need to be considered carefuly.

We should also consider how it relates to streams / comprehensions because I think we'll want a seperate syntax for LINQ-like operations that is probably more directly related to Plasma's loop syntax.

PaulBone avatar Feb 07 '20 13:02 PaulBone