Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Lists are given to the reader in angle brackets and printed in parentheses, or at least that's how it looks. I suppose the other possibility is that these are actually different types

They are different types:

[1,2,3] is an array with mutable elements that can be expanded, shortened (1,2,3) is a list with immutable elements of fixed length

> find an example of anyone actually using it

A common example of signature introspection is when a routine accepts a lambda as a parameter, and adapts its function depending on the number of arguments the lambda expects (the arity: &foo.signature.arity, see https://docs.raku.org/syntax/Arity).

Two examples:

The "sort" function optionally accepts a lambda: if that takes one argument, then a Schwarztian transform will be done under the hood. If it takes two, then the lambda will be used as the comparator.

The "map" function expects a lambda. Depending on the number of arguments it takes, it will take that many arguments each time from the iterator it runs on.

say (1..12).map( -> $a, $b, $c { $a - $b * $c } ) # (-5 -26 -65 -122)



> They are different types...

Okay, we have arrays and tuples in square brackets and parens respectively. Where do the angle brackets come in?

> when a routine accepts a lambda as a parameter, and [via runtime introspection] adapts its function depending on the number of arguments the lambda expects

I note from the article that Raku has explicit multiple dispatch. This appears to be the same thing by other means, but probably much harder to optimize.

If so, this would be an application of the same "TIMTOWTDI" principle that governed much of Perl 5's design. But that takes us back to the encouragement of idiolect and the fanaticism for idiosyncrasy, on which I have said a fair bit already. Beyond impugning "ease of writing poetry in it" as an absurd, counterproductive, and frankly twee desideratum in programming language design, I can find nothing more to add.


> Where do the angle brackets come in?

The angle brackets are syntactic sugar for word quoting.

    <a b c>
is syntactic sugar for:

    ("a", "b", "c")
They can be used standalone. Or as postcircumfix on hashes:

    %foo<a>      # the value of key "a" in hash %foo
    %foo<a b c>  # the values of keys "a", "b", "c" in hash %foo
There's a lot more to it than that, but that's the gist of it.

https://docs.raku.org/language/quoting#Word_quoting:_%3C_%3E


Oh, okay, so it's just more sugar over Perl 5-style qw(), which is itself sugar over split().

I heard something once about "cancer of the semicolon"...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: