Fork me on GitHub
#clojure
<
2024-03-31
>
jasonjckn02:03:11

What's the correct syntax for 1.12 alpha9, i thought '.' type hinted, but probably reading outdated content.

R.A. Porter02:03:04

I'm sure it isn't, but that is displaying as an uppercase 'N'.

jasonjckn02:03:27

just my font

R.A. Porter02:03:43

Figured, but thought it was worth confirming.

πŸ™ 1
jasonjckn02:03:10

This works :thinking_face:

seancorfield02:03:53

Yeah, you don't need the . for the method value.

jasonjckn02:03:47

so the bottom example is the idiomatic way?

seancorfield02:03:50

toUpperCase is overloaded on arity (with Locale in the one-argument case) so you need an arity hint ^[] to make it work as mapped method.

πŸ‘ 1
thanks2 2
seancorfield02:03:03

Clojure 1.12.0-alpha9
user=> (map String/toUpperCase ["hello" "world"])
Syntax error (IllegalArgumentException) compiling at (REPL:1:1).
Multiple matches for method toUpperCase in class java.lang.String, use param-tags to specify
user=> (map ^[] String/toUpperCase ["hello" "world"])
("HELLO" "WORLD")
user=>

πŸ‘ 1
Alex Miller (Clojure team)04:03:00

Subject to change :)

πŸ‘ 1
πŸ‘† 1
jasonjckn04:03:03

@U064X3EF3 beta must be getting closer i'd imagine

seancorfield04:03:14

Resolving on arity would make quite a few calls a lot cleaner, so I'd definitely be in favor of that πŸ™‚

seancorfield04:03:50

But could you have both (map String/toUpperCase ["hello" "world"]) and (map String/toUpperCase ["hello" "world"] [(Locale. "en") (Locale. "fr")]) without any reflection, just based on arity @U064X3EF3? I'm curious about that.

seancorfield04:03:05

(I know you could do it with reflection)

Alex Miller (Clojure team)04:03:20

This is an evolving area of design

Alex Miller (Clojure team)04:03:30

But we are moving to a place that will support reflection and probably avoid reflection if arity disambiguates

Noah Bogart11:03:08

Way back in the fall, there was discussion in the core team about prepending a dot for method calls

Noah Bogart11:03:29

But it never made it into an alpha

p-himik11:03:48

@U064X3EF3 Is disambiguating based on a partial but unambiguous signature match on the table? E.g. when some method accepts (String, String) and (Number, Number) and you give it (String, unknown).

Alex Miller (Clojure team)13:03:44

That’s actually a quirk of the reflection filtering. Not planning to fix it in 1.12 but there are a couple things in that area I would like to improve

πŸ‘ 1