In Lisp (any lisp dialect will do) what's the idiomatic way of calling a function with many args?
By many I mean exceeding the 80 character limit.
Say we have an example function called foo-func
that takes a variable number of arguments
(foo-func 'foo 'bar 'baz 'qux 'foo-bar 'foo-baz 'foo-qux 'bar-foo 'bar-baz 'you-get-the-idea)
How would one normally arrange the args if not on a long incomprehensible line?
NOTE this is not a question about personal preference, it's about how it's recommended it's done
Usually, it would be aligned like this:
(foo-func 'foo
'bar
'baz
'qux
'foo-bar
'foo-baz
'foo-qux
'bar-foo
'bar-baz
'you-get-the-idea)
In some cases, you might put several arguments that belong together on one line:
(foo-func 'foo
'bar
'baz
'qux
'foo-bar 'foo-baz 'foo-qux
'bar-foo 'bar-baz
'you-get-the-idea)
However, any function that has more than a few arguments would often make heavy use of keyword parameters:
(foo-func 'foo
'bar
'baz
'qux
:barista 'foo-bar
:bazaar 'foo-baz
:quxfrog 'foo-qux
:baroofa 'bar-foo
:barazza 'bar-baz
:say-what 'you-get-the-idea)
Here, you could perhaps put the required parameters on one line:
(foo-func 'foo 'bar 'baz 'qux
:barista 'foo-bar
:bazaar 'foo-baz
:quxfrog 'foo-qux
:baroofa 'bar-foo
:barazza 'bar-baz
:say-what 'you-get-the-idea)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With