guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Strongly typed language my ass


From: Jacob Hrbek
Subject: Strongly typed language my ass
Date: Tue, 20 Sep 2022 09:01:01 +0000

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

Attachment: publickey - kreyren@rixotstudio.cz - 0x1677DB82.asc
Description: application/pgp-keys

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]