IRC channel logs

2022-08-23.log

back to list of logs

<haugh>Is it possible to use the value of a variable in a pattern match without syntax?
<haugh>In Elixir, for example, this is called "pinning" the variable; its value is accessed rather than rebound. This would make things like match-let substantially more useful.
<drakonis>i'm not sure if i follow
<drakonis> https://www.gnu.org/software/guile/manual/html_node/Pattern-Matching.html
<drakonis>scheme doesnt exactly have a lot of syntax
<haugh>drakonis, in the following _broken_ code, I've used quasiquote to indicate the pattern I want, where the value of foo would be applied to the pattern. The idea is to chain matches, generating new patterns. When I say "without syntax" I mean "without macros". Apologies for being vague, I'm new.
<haugh>(match-let* ([foo 'bar]
<haugh> [(`foo qux) '(bar target)])
<haugh> qux)
<haugh>I understand that this is not how ` actually works in this context.
<flatwhatson>haugh: are you saying that the contents of the foo variable should dynamically generate a pattern for match?
<flatwhatson>match is a macro, it basically takes your pattern and compiles it to some destructuring operations
<haugh>flatwhatson, I just want to use variables to generate patterns.
<flatwhatson>haugh: a pattern gives names which are bound in the scope for matching elements. there is no way those names could come from a variable. are you sure you actually need a destructuring pattern match for this?
<flatwhatson>it seems like you just need equality testing or something
<haugh>alright that's pretty definitive, thanks
<haugh>Yeah this comes more from my experience with pattern matching in other languages than any specific need. I'll just adapt
<flatwhatson>you could use eval to generate patterns at runtime, but it's probably the wrong approach
<flatwhatson>notice that you can embed predicates with the (? pred ...) syntax, so you could do something like:
<flatwhatson>first match, extract the symbol you need. let bind a predicate which checks equality to that symbol. second match using the predicate
<tohoyn>if I compile a Guile program to a .go file should I call the target file bytecode or objcode?
<flatwhatson>tohoyn: the .go file is an object file containing bytecode
<tohoyn>flatwatson: tx
***Guest8836 is now known as roptat
<mwette>haugh: Could you give a simple example? I think it might be doable. Look at installed .../share/guile/3.0/system/base/pmatch.scm for simple version of match.
<mwette>Are you saying that the form is like (h-match expr proc (<arg> <expr) ...) where proc is applied to each <arg> to generate a pattern to match to expr ?
<dsmith-work>Tuesday Greetings, Guilers
<dsmith-work>sneek: botsnack
<sneek>:)
<dsmith-work>goodbot
<dsmith-work>!uptime
<sneek>I've been running for 14 days
<sneek>This system has been up 2 weeks, 11 hours, 6 minutes
***justache is now known as justache_
***justache_ is now known as justache