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

Repetitions in method calls #389

Open
usaoc opened this issue Oct 15, 2023 · 1 comment
Open

Repetitions in method calls #389

usaoc opened this issue Oct 15, 2023 · 1 comment

Comments

@usaoc
Copy link
Collaborator

usaoc commented Oct 15, 2023

Consider something like

#lang rhombus/static
def [n, ...]:
  for List (i: 0..3):
    i

def [lst :: List, ...]:
  for List (i: 0..3):
    [i]

[lst.remove(n), ...]

or

#lang rhombus/static
def [n, ...]:
  for List (i: 0..3):
    i

class Foo(x):
  method add(y):
    Foo(x + y)

def [foo :: Foo, ...]:
  for List (i: 0..3):
    Foo(i)

[foo.add(n), ...]

these programs error with “cannot use repetition binding as an expression.” On the other hand, simply switching to dynamic dispatch makes them work.

@usaoc
Copy link
Collaborator Author

usaoc commented Dec 14, 2023

A bigger problem, I think, is that dot providers are currently invoked with a parsed expression as the left-hand side. This means that the dot provider for methods cannot have a chance to compose the compound repetition before the left-hand side has already been processed. A possible solution is to allow dot providers to be aware of repetitions (and be invoked with a parsed repetition as the left-hand side), but there are likely other drawbacks.

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

No branches or pull requests

1 participant