onyx-lang icon indicating copy to clipboard operation
onyx-lang copied to clipboard

Feature request: Splat support in block arguments.

Open stugol opened this issue 9 years ago • 3 comments

a-function(...args) -> yield args
a-function(1, "", false) ~> |...args| puts args

Currently not possible in Crystal.

stugol avatar Feb 22 '16 00:02 stugol

Slight correction to the example (and generally, I'd recommend using "say" for informal stdout shout outs - the name reflect the use better imo, but no guns held to the head here ;-) ): a-function 1, "", false, (...args) ~> say args

Anyway, I'd be happy to see some more "practical" examples, because I can't see myself in use of that. Care to enlighten? Also - if you've already posted issues, for instance in crystal issues, links there are acceptable, since I'll undoubtedly make contributions upstream too.

ozra avatar Feb 24 '16 21:02 ozra

crystal issue

Logically, if you need variadic methods, then you also need variadic blocks.

stugol avatar Feb 24 '16 23:02 stugol

Looking over there, my instant reaction was "that should be a macro", which I then saw you did use.

It seems you're coding in a very "dynamic lang mindset". All things are solvable by attacking it from a new perspective.

This is a language primarily targeted at performant code. Statically type checked - because it generates faster code, and is scientifically more productive and safer. Those are the pillars.

Trying to "dynamify" that is like building a ladder reaching around a wall sideways instead of just opening the door and go through.

soft lambdas != methods, so there's really no logic "carry over".

If there really is a good use case, that isn't already solvable equally or better, then it's time to:

  • spend all those hours away from family, friends and life matters (needed to code any feature)
  • increasing complexity of the compiler, (unavoidable with any feature)
  • reducing free syntactical combinations (that might turn out to be better needed for another feature in the future.)
  • etc.

There are always costs! And there are many choices of where to spend, so we require real motivation, not implied logics.

ozra avatar Feb 25 '16 13:02 ozra