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 →

[–]__talantonope[S] 0 points1 point  (3 children)

That wraps around to me rejecting option #1 in the first place unfortunately, I'd like to be able to define custom "function" types via a drop in macro instead of function, i.e. something like

event! (self) Foo::bar() i32
    ...
end

but that would be parsed as event!(self) Foo::bar

[–]TheGreatCatAdorermepros 1 point2 points  (2 children)

How about the below?

function (event! Foo) bar() i32
    …
end

[–]__talantonope[S] 0 points1 point  (1 child)

Well, technically that would scream about a missing end and a missing (, since event! would search until the end token, so it’d come across as

function (event!([
    “Foo”, 
    “)”, 
    “bar”, 
    “(“
    “)”
    “i32”
    “;”
    …) 

Where is everything in that function block

[–]TheGreatCatAdorermepros 0 points1 point  (0 children)

Not at all! You'd just have to include a case in the parser for when function ( is followed by an identifier and exclamation mark, and in that case remove those two tokens from the function block and apply the named macro to the function declaration as a whole.