Thomas Morley <[email protected]> writes: > Am So., 17. Nov. 2019 um 18:13 Uhr schrieb <[email protected]>: >> >> > -----Oorspronkelijk bericht----- >> > Van: David Kastrup <[email protected]> >> > > I did use a lot of define-method, as it is easy this way to be type >> > > save. >> > >> > I don't think the cost justifies the effort here. Scheme is not intended >> > as a >> > "type safe" language. > > What disturbs me are things like: > > (define-method (->number (value <boolean>)) > (cond (value 1 (else 0))) > )
Of course that one is wrong. It doesn't particularly help that this obviously is not at all used for improving type safety but instead is a tool for promoting type laxness. > (define-method (->number (value <number>)) > value > ) > > (define-method (->number (value <string>)) > (string->number value) > ) Same here. > I'd always sort the arg in procedure's body, like > > (define (->number arg) > (cond ((number? arg) arg) > ((boolean? arg) (if arg 1 0)) > ((string? arg) (string->number arg)) > (else #f))) Actually this seems like a way to be extra sloppy. Turning everything into a number instead of having the caller provide what is actually required seems suspicious. In formatting applications, there may be some rationale for turn-everything-into-a-string behavior. But turn-everything-into-a-number behavior stinks a bit. I have to admit of only having read the mails so far and not the code wholesale. -- David Kastrup
