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

new syntax sugar for anonymous objects #3704

Open
yegor256 opened this issue Dec 19, 2024 · 6 comments
Open

new syntax sugar for anonymous objects #3704

yegor256 opened this issue Dec 19, 2024 · 6 comments
Assignees

Comments

@yegor256
Copy link
Member

yegor256 commented Dec 19, 2024

Consider this code:

malloc.of
  100
  [m] >>
    QQ.io.stdout > @
      m.read 0 10

It would be more convenient to write it shorter:

malloc.of 100 [m] >>
  QQ.io.stdout > @
    m.read 0 10

This will save one indentation.

@yegor256
Copy link
Member Author

@maxonfjvipon WDYT?

@maxonfjvipon
Copy link
Member

@yegor256

  1. Looks like a mixing of a vertical and horizontal notations in application
  2. It's hard to understand if >> should be applied to anonymous object or whole application

@yegor256
Copy link
Member Author

yegor256 commented Dec 19, 2024

@maxonfjvipon indeed, it's a mix of notations. How about this instead:

malloc.of 100 [m]>>
  QQ.io.stdout > @
    m.read 0 10

Which is very close to what we do in Ruby:

malloc.of 100 { |m|
  puts "hello"
}

@maxonfjvipon
Copy link
Member

@yegor256 better, but still... if we allow the mixing in such case, it'll be possible to write something like this:

sum 1 2
  3

We prohibited on purpose some time ago

@yegor256
Copy link
Member Author

@maxonfjvipon we won't allow this, just one special case, with the [...]>> at the end

@maxonfjvipon
Copy link
Member

@yegor256 ok, I'll try to introduce it into our grammar

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

No branches or pull requests

2 participants