Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object-method notation #222

Open
PaulBone opened this issue Feb 7, 2020 · 0 comments
Open

Object-method notation #222

PaulBone opened this issue Feb 7, 2020 · 0 comments

Comments

@PaulBone
Copy link
Member

@PaulBone PaulBone commented Feb 7, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.