> Le 20 sept. 2022 à 23:44, Jacob Hrbek <krey...@rixotstudio.cz> a écrit :
> 
> 
> In what world is this considered a strongly typed language when I need to do 
> these checks like it's a weakly typed one?
> 
>     (define* (lazy-assign key #:optional (val ""))
>       "Assign environmental variable KEY with an optional value VAL, both  
> must be a string or a thunk that evaluates to a string
> 
>     This procedure sets an entry in the @{%makevars} hash table"
> 
>       (cond ((procedure? key)
>     (set! key (key)))
>     ((string? key)
>     ;; FIXME-QA(Krey): Seems like a wasteful @{format}
>     (set! key (format #f "~a" key)))
>     ;; FIXME-QA(Krey): Make sure that the error here is clear and descriptive
>     (else (make-non-continuable-error)))
> 
>       ;; FIXME-QA(Krey): Add check for sanity of VAL
> 
>       (makevars-set key (delay val)))
> 
> Instead of something like:
> 
>   (define* (lazy-assign (string-type key) #:optional (val ""))
>   "Assign environmental variable KEY with an optional value VAL, both must be 
> a string or a thunk that evaluates to a string
> 
>   This procedure sets an entry in the @{%makevars} hash table"
> 
>   (makevars-set key (delay val)))
> 
> Notice the (string-type key) meant to declare that it's only expecting an 
> input that is a string or evaluates into a string which mitigates the need to 
> include sanity checking in every procedure..
> 
> or even something like:
> 
>     (define* (lazy-assign key:string #:optional (var:string "")) ...)
> 
> -- Jacob "Kreyren" Hrbek




https://www.gnu.org/software/guile/manual/html_node/GOOPS.html

Writing that denigrates is unlikely to attract helpful responses. I won’t reply 
further.

Reply via email to