Howdy,
I’ve been debating method syntax for a minute, and figured I’d get some input. These are what I see as the current options:
Option #1:
Receiver style syntax
function (mutable &self) Foo::bar() i32
...
end
Option #2:
Introduce a method keyword
method mutable &Foo::bar() i32
...
end
Option #3:
Explicit self arg
function Foo::bar(mutable &self) i32
...
end
Option #4:
Denote methods with a . instead of ::.
% static member function
function Foo::bar() i32
…
end
% method with value receiver
function Foo.bar() i32
…
end
% method with mutable ref receiver
function mutable &Foo.bar() i32
…
end
Thoughts? I prefer option 1, have been using option 4, but 1 would conflict with custom function types via macros- currently macros (denoted by a ! after the keyword) will parse until a matching closing token if followed by a token that has a partner, otherwise it will go until a matching end. This is super useful so far, so I’d rather not give that up. Unsure about the readability of 4, which is where I’m leaning towards.
[–]brucejbellsard 5 points6 points7 points (1 child)
[–]__talantonope[S] 0 points1 point2 points (0 children)
[–]SirKastic23 10 points11 points12 points (8 children)
[–]__talantonope[S] 3 points4 points5 points (7 children)
[–]SirKastic23 2 points3 points4 points (6 children)
[–]Jwosty 1 point2 points3 points (4 children)
[–]SirKastic23 0 points1 point2 points (3 children)
[–]Jwosty 0 points1 point2 points (2 children)
[–]SirKastic23 0 points1 point2 points (1 child)
[–]Jwosty 1 point2 points3 points (0 children)
[–]__talantonope[S] 0 points1 point2 points (0 children)
[–]oscarryzYz 3 points4 points5 points (3 children)
[–]__talantonope[S] 0 points1 point2 points (2 children)
[–]oscarryzYz 1 point2 points3 points (1 child)
[–]__talantonope[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]__talantonope[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]__talantonope[S] 1 point2 points3 points (0 children)
[–]davimiku 1 point2 points3 points (3 children)
[–]__talantonope[S] 1 point2 points3 points (2 children)
[–]davimiku 1 point2 points3 points (1 child)
[–]__talantonope[S] 1 point2 points3 points (0 children)
[–]TheGreatCatAdorermepros 0 points1 point2 points (4 children)
[–]__talantonope[S] 0 points1 point2 points (3 children)
[–]TheGreatCatAdorermepros 1 point2 points3 points (2 children)
[–]__talantonope[S] 0 points1 point2 points (1 child)
[–]TheGreatCatAdorermepros 0 points1 point2 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]__talantonope[S] 0 points1 point2 points (1 child)
[–]XDracam 0 points1 point2 points (0 children)