Re: Question about &rest, &key, and &allow-other-keys
From: rif (rif_at_mit.edu)
Date: 01/19/04
- Next message: Brian Mastenbrook: "Re: Programming languages for the very young"
- Previous message: Brian Mastenbrook: "Re: Programming languages for the very young"
- In reply to: Erik Naggum: "Re: Question about &rest, &key, and &allow-other-keys"
- Next in thread: Erik Naggum: "Re: Question about &rest, &key, and &allow-other-keys"
- Reply: Erik Naggum: "Re: Question about &rest, &key, and &allow-other-keys"
- Reply: Tim Bradshaw: "Re: Question about &rest, &key, and &allow-other-keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Brian Mastenbrook: "Re: Programming languages for the very young"
- Previous message: Brian Mastenbrook: "Re: Programming languages for the very young"
- In reply to: Erik Naggum: "Re: Question about &rest, &key, and &allow-other-keys"
- Next in thread: Erik Naggum: "Re: Question about &rest, &key, and &allow-other-keys"
- Reply: Erik Naggum: "Re: Question about &rest, &key, and &allow-other-keys"
- Reply: Tim Bradshaw: "Re: Question about &rest, &key, and &allow-other-keys"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|