Named and implicit arguments

65 views
Skip to first unread message

Hanns Holger Rutz

unread,
Sep 17, 2014, 2:59:08 PM9/17/14
to scala...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Coming across this:
https://stackoverflow.com/questions/22552985/scala-passing-one-implicit-parameter-implicitly-and-the-other-explicitly-is-it

Ex.

def foo(implicit a: Int, b: String) = println(a, b)

It appeared to me that using named arguments could be a way to
unambiguously explicate only selected arguments. That is, this doesn't
work right now:

implicit val x = "abc"

def foo(33) // [1]

or

def foo(a = 33) // [2]

But I think that [2] would indeed make sense? I have many cases in my
libraries where indeed you can get up to five or more implicit
arguments, and when inference doesn't kick in with one of them, it's
always a PITA having to specify all the rest that are actually found
by Scalac.

What do you think?

Best, .h.h.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUGdnyAAoJEKZFmaPaYk6QO8EP/18two1iUeAaPTLlc9AzlQPh
N8F9/Rztk9xocA1EODbI8MA5jzF/SfI7c/5J6xadG0qJoXrPSGHsVm6y16coEUED
RXFxVX/YjJOBdyjBpgmCOqBYnugAI9P8VCJ1z48C+4JlU0fxfzn5UK3uubkzR+EF
1W5qQzEuedJrdHkYsjl+i6TqgruG2Gm0T4BIrNvxQ754lbjELS4J4UtlFftFBAor
3+ESbaSnNRVlsWDN0aX6yRdxvKqte6I7vB/Ochu6aIDMOWIU1fjqvjT9KX173XIR
kNdI5P3IeyZ3EiEfyydU388d0ieTX39v8tGH7RVMA6dVny9NWBzw4Gk17P/x5Ql+
2WSrHjKI5w6dYUGO44sGzeQiFFibfGSXxdDHMlpS0g8NQesMWKoIzPmYSHZJH9LE
z5JsVy9Hbi9dKbJ0k6TpGlZ8+LXlsdnbO6hBX00MDYInRNuqv8IBQ9eebUj/Jlx4
DuzB75zpAxbFJKKJziejeBB9AW4b+mh1MxiwiOkKUMNoo1iTncSKGFKLya0u/F02
+zqlkk87Fv7fm7DSQXx+S9M2GZvepz3ImhC4/G4aW8hmdoU9l9oRgf9EaxauMnxn
vVQtZchu9CF2EswMnn1YT7Krcd06U9nPurrOKAFffotGwE14a4cQDgma0y/TJ8ga
j9vNiPY5HnVLI0AZnNuW
=rpSm
-----END PGP SIGNATURE-----

Hanns Holger Rutz

unread,
Sep 17, 2014, 3:00:31 PM9/17/14
to scala...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/17/2014 09:59 PM, Hanns Holger Rutz wrote:
> implicit val x = "abc"
>
> def foo(33) // [1]
>
> or
>
> def foo(a = 33) // [2]

of course these are calls, without the `def`!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUGdpJAAoJEKZFmaPaYk6QJuIP/Rk87n6dRO+ja3KNOl8PPCib
piVA87ZSZUcYYjS93b/sJZHN3CPJepogMS287IRpTJU0ASnz/MPhkADkaH2AKsEO
RQi0pC9T+sJUkOSwCBGYeuiStVplY/xUFVE+JW1iNwHFQn/XUj+fFtZ9ENu80rqw
Y9n4wSoBZuYxImZf5ebCLXWN6CNyd7hyUx0UiSbxVGFqZnMIJ/T1dv6DXFJmu/rq
jX1y9VAByk+0DpTrT7sZsRJT0xNwrENtdSHE1+nYc4CpeuRZyMqyz9hJMv6kwpFr
jOJVKoRgecpaJBoTUrtcDnl2y7OP77atUaLO+h7m5+2RcYWks85i5pPDiAIo/Z/m
QUnE7D/c4H0fKFQdYi92oyloqaih3lN5WzRbPhwoRY3iZTpTqnAbcUe04cjZiMEF
/q7oYAhrRAIo0yB/Dk8s3hbHRlECmijtpOr2A+ePN1DrhcVxxB74JtbG7KzcxRCX
zrHlGBxZuVyGXDmaxbhFfIqOQPXCBVZmxNGeCler5SD2kvZGYZM8CaD38pvqlDTQ
vghQrCLeoKV3c7JRO9PpJ0cZaY/F8JrfA2PYzZDeTl0DRMo0e6dAIzN5p3tnOELb
Mfu2EMzeO+PULyxFTCFcFjBkZwe9e4awhXgXvdmhU23b15lcIZMZCPGf4qKLuiOA
aojQxknVLYpZ+nBYT6VL
=AP0X
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages