IRC channel logs
2024-09-17.log
back to list of logs
<mwette>reyman: I don't have much experience with that. I would try to compile all my stuff without optimization: `guile compile -O0 mymodule.scm` <haugh>Is there any difference between #(foo) and #1(foo) ? They are EQ?, but their literal format may be output by different procedures. When I'm working with arrays, is there any problem that could arise from preferring to use the implicit syntax to describe literals? <haugh>To be clear, the only thing that throws me is (array-slice #2(() ()) 1) => #1() in the REPL. <lloda>haugh: literal #1(x) is the same as #(1) <lloda>the difference is that actual vectors are written as #(), while rank-1 arrays that aren't vectors are written as #1(...) or #1@a:b(...) etc <lloda>array procedures work on either, but vector procedures only work on actual vectors <lloda>for example something like (make-shared-array #(1 2 3) (lambda (i) (list (+ 1 i))) 2) is #1(2 3) and not #(2 3), because it's a view on #(1 2 3), which cannot be a vector <lloda>vectors are always containers, and arrays are always views, even when you use make-array, there is an underlying (maybe typed)-vector that you can get at with shared-array-root <lloda>sometimes make-shared-array (or array-slice etc.) can return a vector and not a view, but that only happens when the result is identical to the root <lloda>the thing with an empty view like the one you get from (array-slice #2(() ()) 1) is that you might still want to get shared-array-root or shared-array-offset of that view, so i think it makes sense to return a view and not (say) a unique global #() in this case <haugh>lloda, Ahhhhh thank you very much! <haugh>I do think it's a bit confusing that #1() and #() are EQ?, EQUAL? and ARRAY-EQUAL? despite (vector? #1()) => #f, but this idea of "views vs containers" is a much more useful intuition than what I was growing. <lloda>yw. Note that (vector? #1()) => #t if you just write that on the repl, since #1() is the same literal as #() <lloda>it's the particular #1() you got that is (vector? #1()) => #f, which is why it's written #1() <lloda>that is (eq? #() (array-slice #2(() ()) 1)) => #f <haugh>WOW I can't believe I took the literal for granted again. Fantastic, now it all makes sense. <avv>hi. Question for syntax-case: how do I write a pattern that only matches when the form contains a symbol? For example the pattern (_ x y z) matches on any form with 3 arguments, but how do I only match forms that literally have the three symbols x y z in them? I had no luck with (_ 'x 'y 'z) lol :( <haugh>avv, that's what the literals list is for: (syntax-case stx (x y z) (pat expr) ...) Then you can just use those bare symbols in the pattern and they'll match (or not)