Propose: make captured proc type declaration optional

currently there’s a distinction between captured block and not captured block,
It’s mental burden for user to remember there’s a difference between captured block and not captured block, can we unify this?

Propose: compile proc to prototype bytecode(*.crgb level if no type information gives, the bytecode format follows this discussion
), when real call instantiate it.

I don’t think this is possible. If it were, it would’ve already been made so.

Captured blocks become procs, i.e. anonymous functions that transition over to the runtime.
Inlined blocks are basically syntax sugar to compose methods from templates at compile time.

There’s no way to combine those two into one.
I agree that it can sometimes be hard to tell them apart. This is because they’re both grown out of the same syntax. I believe in Ruby there’s not such a hard difference between captured blocks and inlined blocks, so they use the same syntax.

There are some ideas to express the difference more clearly, but little detail changes: Continue with anonymous block arguments · Issue #8764 · crystal-lang/crystal · GitHub

1 Like

Well there is, by forcing inlined blocks to adhere to the same limitations wrt declarations etc as captured blocks do. That sounds really bad, mainly because the limitations on captured blocks are sometimes quite inconvenient, so I by no means would argue for it, but it certainly is possible.

1 Like

Yeah, that would effectively mean dropping the inlined block semantics entirely and replace them with captured block semantics. That would be a form of combining them, I guess. :person_shrugging: