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

* Re: Strongly typed language my ass
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Jean Abou Samra @ 2022-09-20 21:58 UTC (permalink / raw)
  To: Jacob Hrbek; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1746 bytes --]



> Le 20 sept. 2022 à 23:44, Jacob Hrbek <kreyren@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.


[-- Attachment #2: Type: text/html, Size: 3207 bytes --]

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

* Re: Strongly typed language my ass
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Gwozdziewycz @ 2022-09-20 22:17 UTC (permalink / raw)
  To: Jacob Hrbek; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 2088 bytes --]

The words you’re actually looking for are “statically typed” and “dynamically typed.”

Scheme is “dynamically typed.” Some people use the words “strongly typed” to refer to the phenomena that variables must be explicitly converted to another type to be used in a different context. Eg, a string cannot be added to an integer without explicit conversion of one of those to the other.

Maybe seek definitions for these things before making inflammatory comments in the future?

Cheers,

apg

> On Sep 20, 2022, at 14:44, Jacob Hrbek <kreyren@rixotstudio.cz> wrote:
> 
> 
> 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 #2.1: Type: text/html, Size: 3550 bytes --]

[-- Attachment #2.2: publickey - kreyren@rixotstudio.cz - 0x1677DB82.asc --]
[-- Type: application/octet-stream, Size: 661 bytes --]

-----BEGIN PGP PUBLIC KEY BLOCK-----

xjMEYAl3FhYJKwYBBAHaRw8BAQdAQKApmdR8tG9aKEdxwHJ/ZKO2CvZMRWPt
BNNGqJUhp2LNL2tyZXlyZW5Acml4b3RzdHVkaW8uY3ogPGtyZXlyZW5Acml4
b3RzdHVkaW8uY3o+wo8EEBYKACAFAmAJdxYGCwkHCAMCBBUICgIEFgIBAAIZ
AQIbAwIeAQAhCRCt030Uq0L8qRYhBBZ324KTjKhlc4EjB63TfRSrQvyp57QA
/0tlbdnCIzreKXmvW2XSYXzAJotJdxCzE+XATM+qPDKzAQCcbHp7yw6+Arng
eStGFn/olhxTPdpu641CLGigPmEoBc44BGAJdxYSCisGAQQBl1UBBQEBB0Da
iI3jQfSoi3DZ4/NfmxGdsRsv9/BqMgW5j6jdBqkyIAMBCAfCeAQYFggACQUC
YAl3FgIbDAAhCRCt030Uq0L8qRYhBBZ324KTjKhlc4EjB63TfRSrQvypHcEB
AOQxS/J/UM0ee8k2jbliWd/Q0Id+X8UHBXhyqVRc22qrAQDLHcW97WQbSJFo
19kwt70OyHepF6LWpDD0PuISZD6ICg==
=9kZg
-----END PGP PUBLIC KEY BLOCK-----

[-- Attachment #2.3: Type: text/html, Size: 178 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).