Re: Question about &rest, &key, and &allow-other-keys

From: rif (rif_at_mit.edu)
Date: 01/19/04


Date: 18 Jan 2004 22:47:17 -0500


OK, thanks for the info.

The reason I don't just put the default arguments into the constructor
for the call is that I need a bunch of different "sets of defaults".
The structure holds a bunch of parameters that control how a
computation goes. In a given experimental setting, there will be a
number of these parameters that take on the same defaults, and then
I'll also need to vary one or two more. So if I have scenarios A and
B and C, I need different sets of defaults for each scenarios, with
the additional ability to specify individual parameters manually. For
this reason, I don't think :CONSTRUCTOR can help me either, as I need
several different sets of defaults.

I can see three possible solutions, and I'd be interested in hearing
which other people might choose and why, or any other ideas.

1. Suck it up and write functions that contain the defaults I need
    both in the parameter list and in the apply call, which is what
    I'm already doing:

> (defun make-my-foo (&rest params &key (d 10) (g 3) &allow-other-keys)
> (apply #'make-foo :d d :g g params))

2. Write a macro to take a minimal specification of what I want and
    generate the functions.

3. Switch to CLOS, make each separate set of defaults a new class
    that inherits from the base "control object", with the same fields
    but different defaults.

Cheers,

rif



Relevant Pages

  • Re: a method to make js have the ability to inherit
    ... but without the implied type-conversion of the string ... that uses the name of a specific constructor. ... programmer has no idea at all what types of object they are ... no reason for ever doing so. ...
    (comp.lang.javascript)
  • Re: return values of multiple datatype
    ... I'd make IntStr have a suitable constructor so that the ... When you want different kinds of things in an array, ... instances of a class with a bunch of fields. ...
    (comp.lang.java.programmer)
  • Re: About John McCain
    ... A bunch of people mesmerized by a handsome young face who ... nomination within the rules set by the Republic Party. ... Oh, Bush didn't help, but he wasn't the main reason McCain lost. ... unsolicited credit card offers, so don't tell me credit is drying up. ...
    (misc.transport.road)
  • Re: Birdman breaks up with Safarova
    ... them to date a bunch of people. ... It would be stupid not to.< ... I don't make up the stats. ... The right reason is when you have that connection with someone who's different from everyone else, & you really see yourself staying with them & happy for 50 years. ...
    (rec.sport.tennis)
  • Re: Structs cannot contain explicit parameterless constructors
    ... I don't know what the real reason is but it may have something ... constructor it would not be called unless you recompiled. ... much influence on the language design. ... IdentityStamp id = obj.Id; ...
    (microsoft.public.dotnet.languages.csharp)