> it could be a single symbol instead of two

even if this can be done without parser ambiguity, it suffers from visual
ambiguity with the assignment operator.

consider what this would look like if the expression itself uses the
assignment operator...

    f($x) = $y = $y + $x;

versus something like:

    f($x) => $y = $y + $x;

even that is visually ambiguous when used in arrays though:

    $a = [
        "foo" => f($x) => $y = $y + $x,
    ];

also unreadable.

even if the parser can cope, I think we need some other symbol that isn't
visually ambiguous when used in these contexts?


On Thu, Jun 8, 2017 at 5:56 PM, Fleshgrinder <p...@fleshgrinder.com> wrote:

> On 6/7/2017 9:45 PM, Rasmus Schultz wrote:
> >> the `fn($a, $b) => $a + $b ** $c` syntax suddenly becomes an acceptable
> > compromise.
> >
> > I have to second that.
> >
> > I might even propose to shorten it from "fn" to just "f" - the resulting
> > syntax then resembles a mathematical predicate :-)
> >
>
> I really like your thinking here. +1 for just `f`.
>
> I am not sure why we would require the fat arrow anymore. We most
> probably want some symbol there to separate the return type constraint
> from the body, but it could be a single symbol instead of two:
>
>     f($x) = $x^3
>     f(int $x): int = $x^3
>
> We could go full math here! :)
>
> --
> Richard "Fleshgrinder" Fussenegger
>
>

Reply via email to