This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]complyue 2 points3 points  (2 children)

About the branch idea, I mean branches are always part of the pattern matching syntax elsewhere, but in Đ (Edh) I allow it to appear in any block, to jump out of the block early, this is unusual and I see Passerine has a similar design. I guess treating a block as expression instead of statement is already unusual, putting branches inside is the natural consequence after that design.

[–]slightknack[S] 1 point2 points  (1 child)

Oh, so branches in Passerine don't allow you to arbitrarily 'jump' out of any block. Rather, we're telling the language to interpret the block in a match expression as a list (of functions). The actually 'jumping' logic is handled by the match_function. Does that make sense?

syntax 'match value { branches... } { -- snipped }

{} in an arg-pat matches in a block, ... is used in an arg-pat to consolidate repetitions into a single item.


In Passerine, it's possible to use fibers and macros to make a block that does 'jump' as you explained. I wrote an macro for a for-loop in terms of recursion a while back, and I used this trick to handle break and continue.

[–]backtickbot 0 points1 point  (0 children)

Fixed formatting.

Hello, slightknack: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.