A comparison by example of keyword argument styles

Nikolai Weibull wrote:

Trans wrote:

> List is great but I don't program in Lisp because of my eyes become
> crossed in looking at it. I don't what the same thing in Ruby.
>
> def foo( c: ) # looks bad
>
> foo( c: :many ) # horrible!!!

Since you write "foo( c: :many )" I don't understand why you are worried
about not being able to remove the space between symbols and the keyword
argument. You obviously like your whitespace in abundance as you put in
the horribly looking spaces after and before opening and closing
parentheses.

Hey, blame _why I picked up the habbit from him :slight_smile:

Even so, its a preference not a neccessity, and to me it helps
readability. c: :many does not.

T.

For my part, I prefer this syntax. Its natural to Lisp programmers,
relives much of the parsing burden on the core code and is easy to
understand for people who haven't ever used Lisp. I can't see what's so
ugly about this syntax and I don't find much sense in Trans' arguments. As
for Sydney's syntax, it too is nice, but I would prefer the syntax that
can be parsed the fastest; Ruby doesn't need to get any slower before
YARV integration. I already have to write C extensions to do some stuff at
reasonable speeds, exactly the thing I got into Ruby to avoid :wink:

···

On Sun, Oct 23, 2005 at 11:57:49PM +0900, Daniel Berger wrote:

I could live with this particular exception. Seriously, what are our
alternatives for keyword syntax in method calls?

"foo(x: 1)"
Pros: Probably easiest to parse. Familiar to Smalltalkers and Lispers.
Cons: Symbols force space, look ugly.
Aside: I don't expect to see a lot of folks passing symbols to keywords
arguments in practice.

--
Toby DiPasquale

Hi,

···

In message "Re: A comparison by example of keyword argument styles" on Mon, 24 Oct 2005 00:07:01 +0900, "Trans" <transfire@gmail.com> writes:

I hate to say, but it seems like the selection of a character commonly
used for assignment operations, i.e. ':' as a prefix for symbols has
come back to haunt. Go back in time Matz! Throw out the '=>', use ':'
instead, and chose us another symbol symbol!

For example? It that good enough to break thousands of lines of code?

              matz.

Yukihiro Matsumoto wrote:

Hi,

>I hate to say, but it seems like the selection of a character commonly
>used for assignment operations, i.e. ':' as a prefix for symbols has
>come back to haunt. Go back in time Matz! Throw out the '=>', use ':'
>instead, and chose us another symbol symbol!

For example? It that good enough to break thousands of lines of code?

Not if you go back in time it won't :wink:

Might have used backtick `abc, kind of like Lisp 'literal, or maybe
backticks `abc`. Leading underscore _abc might have worked well too.
But as you say, that's a lot of code breaking --that would be a major
shift.

T.

P.S. If you're keeping ':' might you deprecate '::'? That'd help.

···

In message "Re: A comparison by example of keyword argument styles" > on Mon, 24 Oct 2005 00:07:01 +0900, "Trans" <transfire@gmail.com> writes:

Hi --

···

On Mon, 24 Oct 2005, Yukihiro Matsumoto wrote:

Hi,

In message "Re: A comparison by example of keyword argument styles" > on Mon, 24 Oct 2005 00:07:01 +0900, "Trans" <transfire@gmail.com> writes:

>I hate to say, but it seems like the selection of a character commonly
>used for assignment operations, i.e. ':' as a prefix for symbols has
>come back to haunt. Go back in time Matz! Throw out the '=>', use ':'
>instead, and chose us another symbol symbol!

For example? It that good enough to break thousands of lines of code?

No. Nor is there any reason for Ruby to converge onto what's common
in other languages. : for symbols is fine.

David

--
David A. Black
dblack@wobblini.net

Keyword args will make several things harder:
    Inheritance
    Reflection
    Tools that parse
    Linking
    Dynamic Linking

A future version of compiled Ruby might want to:

LibraryPath = [...]
somefunc(a=5, z=9) ## Go find the function "somefunc" on the library path (with
keyarg a and z) , arrange the args, and call it.

After all, they compile lisp, don't they?

With plain old non-dynamic linking, you'd have to generate the code to call 'somefunc'
before you saw it. Will we have include files?

Warren Seltzer