IRC channel logs

2020-03-25.log

back to list of logs

<chrislck>alextee[m]: instead of (unless (eq? (length args) 13) ...) you can actually insert a second MATCH clause with (_ (display "Need 12 arguments") ..etc..) where _ is the 'anything else' match clause
<chrislck>next, now that (main . args) now only does (match args ...), you can now (define main (match-lambda ((this output-file ...)) (_ (display "error"))) thereby can eliminate args
***apteryx is now known as Guest28000
***apteryx_ is now known as apteryx
<rekado_>alextee[m]: instead of reading character by character you could use (dump-port source target) to put everything from the source port (an opened file port) to the target port (e.g. an output file)
<edoput>good morning, is there any guidance on how to do FFI with guile from the community? I've read about SMOB, new foreign types, snarfing macros and finally the dynamic FFI and I'm lost now. It would really help if I could know which approach is useful when, e.g. I guess I should define new types when I want to manipulate them as scheme values but is then required to always add the C layer when I can do dynamic
<edoput>FFI?
<edoput>the dynamic FFI does not expose C structs as scheme values right? I would still need to do this bindings myself?
<alextee[m]>rekado_: oh nice! thanks
<alextee[m]>chrislck: i'll try that, thanks
<chrislck>alextee[m]: finally, as much as I love match, I think you can use case-lambda instead, which removes the need to import ice-9 match
<chrislck>lisp is the epitome of TIMTOWTDI
<alextee[m]>chrislck: can you show me an example/docs?
<alextee[m]>oh found it in the guile manual
<brendyyn>civodul: with (gcrypt mac), is there way to conveniently specify algorithm and get it's length. mac-algorithm just takes an unquoted symbol and returns the id number for it. lookup-mac-algorithm appears to be the same except you give it a quoted symbol. mac-size can't take either and must actually receive the id number, so you must do something like (mac-size (lookup-mac-algorithm 'hmac-sha256)).
<brendyyn>As a user of the module I'd just like to specify the hash, and get the size of. going via this internal gcrypt number is breaking the abstraction layer it seems. i cant do (mac-size 'hmac-sha256)
<civodul>on the contrary! :-)
<civodul>the "number" is actually an opaque object representing a hash algorithm
<civodul>it turns out to not be so opaque, i admit
<brendyyn>apaque like mud.
<civodul>like water, rather
<brendyyn>that's not opaque...
<civodul>that's my point :-)
<brendyyn>i mean, on a serious note, do you think thats how it should be?
<civodul>yes
<civodul>ideally with a disjoint type for hash algorithms
<brendyyn>what's the difference between mac-algorithm and lookup-math-algorithm?
<civodul>try: ,expand (mac-algorithm hmac-sha256)
<civodul>it's a macro-expansion-time lookup
<civodul>with an expansion-time error if you pass an incorrect name
<brendyyn>I have almost finished implementing HKDF (RFC 5869)
<civodul>conversely, lookup-mac-algorithm is a run-time thing
<brendyyn>ok but why should those two different things exist?
*civodul looks it up
<brendyyn>I'm implementing SPAKE2. it's what Magic Wormhole uses. i plan to implement the whole thing in guile. You can lookup that on youtube
<brendyyn>I've never written a macro before, and have only really experienced the fact that they make things confusing and obscure errors.
<civodul>you seem very positive today :-)
<brendyyn>im super positive
<civodul>there's some truth regarding obscure errors, it's a known issue
<brendyyn>im just trying to get to understand things. My simple brain says (mac-algorithm hmac-sha256) and (mac-size hmac-sha256) seem perfectly logical and provide the module user with what they want?
<civodul>mac-size takes a "hash algorithm"
<civodul>a "hash algorithm" is something returned by mac-algorithm or lookup-mac-algorithm
<civodul>a symbol is not a "hash algorithm"
<civodul>that's the way to look at it
<brendyyn>it makes sense
<civodul>"(guile-gcrypt) Message Authentication Codes" mentions it but it needs to be expanded
<brendyyn>ok thanks
<brendyyn>civodul: Oh I just realised I'm an idiot. after the algorithm is provided, it'll probably be called
<brendyyn>algorithm in the function, so you then just run (mac-size algorithm)
<brendyyn>that makes a lot more sense
***ericst_ is now known as ericst
<dsmith-work>{appropriate time} Greetings, Guilers
<str1ngs>sneek: later tell daviid. it seems for language bindings the glib functions/macros g_error g_warning won't work. same with g_log. it looks like g_log_variant should probably work though. does g-golf have enough GVariant support to call 'g-log-variant? if not it's okay this mostly just a request for comment. the documentation for 'g-log-variant. can be found here
<str1ngs> https://developer.gnome.org/glib/stable/glib-Message-Logging.html#g-log-variant
<sneek>Got it.
<str1ngs>sneek: later tell daviid. https://developer.gnome.org/glib/stable/glib-Message-Logging.html#g-log-variant
<sneek>Got it.
<dsmith-work>goodbot
<dsmith-work>Is Mike Gran in here?
<dsmith-work>spk121: Hey hey.
<dsmith-work>spk121: Just built guile with the gmodule branch.
<dsmith-work>spk121: I think the guile executable is still using libtool instead.
*civodul applies the (srfi srfi-171) patch
<civodul>thanks, manumanumanu! :-)