unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Jacob Hrbek <kreyren@rixotstudio.cz>
To: "guile-devel@gnu.org" <guile-devel@gnu.org>
Subject: Strongly typed language my ass
Date: Tue, 20 Sep 2022 09:01:01 +0000	[thread overview]
Message-ID: <3izAWevitpu2Y1OBwQnrCwhVv4CePmVfWKxl-0oCg1yBwy1TfQcHwbHBUk9iNaZcK5WYKxmxebrZpwXAK5qM3s36qWzc1UBHH2D2XbB3jJ0=@rixotstudio.cz> (raw)


[-- 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 --]

             reply	other threads:[~2022-09-20  9:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20  9:01 Jacob Hrbek [this message]
2022-09-20 21:58 ` Strongly typed language my ass Jean Abou Samra
2022-09-20 22:17 ` Andrew Gwozdziewycz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='3izAWevitpu2Y1OBwQnrCwhVv4CePmVfWKxl-0oCg1yBwy1TfQcHwbHBUk9iNaZcK5WYKxmxebrZpwXAK5qM3s36qWzc1UBHH2D2XbB3jJ0=@rixotstudio.cz' \
    --to=kreyren@rixotstudio.cz \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).