forked from alex-eg/sex
keep the parameter-type rule in types, where both readers find it
sex-modules spelled out its own copy of named-arg-type, and its own strip-pub; a parameter shape taught to one would not reach the other.
This commit is contained in:
19
types.scm
19
types.scm
@@ -390,6 +390,25 @@
|
||||
(pair? (cdr arg)) ; 1 element args are always type
|
||||
(not (type-head? arg))))
|
||||
|
||||
;;; `(p (* struct point))' writes the type in one piece and
|
||||
;;; `(p * struct point)' spreads it over the rest; both are
|
||||
;;; `(* struct point)'
|
||||
(define (named-arg-type param)
|
||||
(if (null? (cddr param))
|
||||
(second param)
|
||||
(cdr param)))
|
||||
|
||||
;;; (fn sum ((a int) (b int)) int ...) -> (fn ((int) (int)) int), and
|
||||
;;; (self * const v) is ((* const v)) just as (self (* const v)) is.
|
||||
;;; Anything that names nothing -- a variadic tail -- goes through
|
||||
;;; untouched.
|
||||
(define (arglist-types arglist)
|
||||
(map (lambda (param)
|
||||
(if (named-arg? param)
|
||||
(list (named-arg-type param))
|
||||
param))
|
||||
arglist))
|
||||
|
||||
;;; The last element is a bound unless what precedes it is still
|
||||
;;; waiting for a type name -- a `*', a qualifier, a tag's keyword. C
|
||||
;;; spells a type with one name at most, so a name after a name, or
|
||||
|
||||
Reference in New Issue
Block a user