Continuing the previous conversation, currently I have a syntax like
this:
test_fun = fn do |f|
f.required_args :foo, :bar
f.optional_args :bee, :baz => 'baz'
f.fn do
puts "foo #{foo} bar #{bar} bee #{bee} baz #{baz}"
end
end
test_fun[:foo => 'foo', :bar => 'bar']
The idea will be that required args can either be passed by position
or name. Optional args are always by name, and can have default
values. If you don't provide the required args, the function is
curried (there will also be an explicit curry call, in case you want
to curry despite having all the required args, and a non-curry call
that throws an exception if you don't have enough args).
Can anyone think of a more cunning way of writing this?
Regards,
Guyren G Howe
Relevant Logic LLC
guyren-at-relevantlogic.com ~ http://relevantlogic.com ~ +1 512 784 3178
Ruby/Rails, REALbasic, PHP programming
PostgreSQL, MySQL database design and consulting
Technical writing and training
Read my book, Real OOP with REALbasic:
<http://relevantlogic.com/oop-book/about-the-oop-book.php
>
--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---