unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Strongly typed language my ass
@ 2022-09-20  9:01 Jacob Hrbek
  2022-09-20 21:58 ` Jean Abou Samra
  2022-09-20 22:17 ` Andrew Gwozdziewycz
  0 siblings, 2 replies; 3+ messages in thread
From: Jacob Hrbek @ 2022-09-20  9:01 UTC (permalink / raw)
  To: guile-devel@gnu.org


[-- Attachment #1.1.1: Type: text/plain, Size: 1457 bytes --]

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 #1.1.2.1: Type: text/html, Size: 2497 bytes --]

[-- Attachment #1.2: publickey - kreyren@rixotstudio.cz - 0x1677DB82.asc --]
[-- Type: application/pgp-keys, Size: 661 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-20 22:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20  9:01 Strongly typed language my ass Jacob Hrbek
2022-09-20 21:58 ` Jean Abou Samra
2022-09-20 22:17 ` Andrew Gwozdziewycz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).