[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating recursive customization types / widgets
From: |
Per Abrahamsen |
Subject: |
Re: Creating recursive customization types / widgets |
Date: |
Mon, 01 Dec 2003 14:27:27 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> (define-widget 'child 'default
> "Base widget for recursive datastructures.
>
> You need to set :type to the widget type for the datastructure you
> want to define, and set :match to a function that matches the
> datastructure. If the datastructure is not recursive, you don't have
> to set :match."
>
> It looks like a good feature, but I can't really understand
> that doc string, so it needs to be somewhat clearer.
Most widget doc strings are much worse, but that's no excuse.
Is the following understandable?
(define-widget 'child 'default
"Base widget for recursive datastructures.
The `child' widget will, when instantiated, contain a single inferior
widget, of the widget type specified by the :type parameter. The
value of the `child' widget is the same as the value of the inferior
widget. When deriving a new widget from the 'child' widget, the :type
parameter is allowed to refer to the widget currently being defined,
thus allowing recursive datastructures to be described.
The :type parameter takes the same arguments as the defcustom
parameter with the same name.
Background: Most composite widgets, i.e. widgets containing other
widgets, does not allow recursion. That is, when you define a new
widget type, none of the inferior widgets may be of the same type you
are currently defining.
In Lisp, however, it is custom to define datastructures in terms of
themselves. A list, for example, is defined as either nil, or a cons
cell whose cdr itself is a lisp. The obvious way to translate this
into a widget type would be
(define-widget 'my-list 'choice
\"A list of sexps.\"
:tag \"Sexp list\"
:args '((const nil) (cons :value (nil) sexp my-list)))
Here we attempt to define my-list as a choice of either the constant
nil, or a cons-cell containing a sexp and my-lisp. This will not work
because the `choice' widget does not allow recursion.
Using the `child' widget you can overcome this problem, as in this
example:
(define-widget 'sexp-list 'child
\"A list of sexps.\"
:tag \"Sexp list\"
:type '(choice (const nil) (cons :value (nil) sexp sexp-list)))"
:format "%{%t%}: %v"
Re: Creating recursive customization types / widgets, Thien-Thi Nguyen, 2003/12/01
- Re: Creating recursive customization types / widgets, Per Abrahamsen, 2003/12/01
- Re: Creating recursive customization types / widgets,
Per Abrahamsen <=
- Re: Creating recursive customization types / widgets, Richard Stallman, 2003/12/02
- Re: Creating recursive customization types / widgets, Per Abrahamsen, 2003/12/02
- Re: Creating recursive customization types / widgets, Richard Stallman, 2003/12/03
- Re: Creating recursive customization types / widgets, Per Abrahamsen, 2003/12/03
- Re: Creating recursive customization types / widgets, Per Abrahamsen, 2003/12/03
- Re: Creating recursive customization types / widgets, Kevin Rodgers, 2003/12/03
- Re: Creating recursive customization types / widgets, David Kastrup, 2003/12/02
Re: Creating recursive customization types / widgets, Ted Zlatanov, 2003/12/01