<zacts>hm... I have an odd question <zacts>I wonder if I can represent all of my web bookmarks in scheme, and guile in particular, via S-XML or something... <zacts>or how one might want to represent this kind of data <zacts>I may want to tag the links too ***androclus is now known as Guest37392
***androclus is now known as Guest91585
***Guest91585 is now known as androclus`
<rlb>Does Guile have any more general-purpose compare function(s) i.e. a total ordering, say for use with an ordered-set. Of course I'd like it to order sensibly within reasonable domains (i.e. reals, strings, symbols, etc.). <mark_weaver>but it would obviously be fairly easy to define such a thing using GOOPS <rlb>(noticed that pfds set requires <) <mark_weaver>yeah, I guess it's a cultural thing: traditionally, scheme avoids even standardizing an equality relation, never mind an ordering relation. <amz3>zacts: you can use assoc list and write them to files <amz3>I think there is no record type that you can directly write <amz3>sxml is verbose, it's a step further in scheme is good but has its downside <amz3>the downside is that it is more scheme code. I understand zacts is starting to learn scheme. I prefer to work with (match) (alist-cons) (alist-delete) and (write alist) than using a record type and serializing to sxml <amz3>you think about using sxml as the primary way to represent to data? <amz3>sneek: later tell stis help! :) <amz3>I'd like to create a custom load procedure that takes a custom reader and an environment <amz3>I looking for load procedure source in guile code but I can't find it <rlb>Does guile have an atomic compare-and-swap! procedure at the moment? <rlb>mark_weaver: ok, thanks. <rlb>mark_weaver: oh, and are any of the primitives guaranteed atomic? (Not critical atm.) <mark_weaver>although now we depends on libatomic_ops via bdwgc, so we could use that. <rlb>Right, or we could just provide a compare-and-swap! that falls back to mutexes on some platforms. <rlb>(been quite a while since I was messing with the C code...) <mark_weaver>but unfortunately, things get messy if the readers don't synchronize as well. <rlb>It'd be fine for me if it were just a specific object type, i.e. a reference holder. <rlb>(compare-and-swap! only worked on that) <mark_weaver>because of out-of-order writes, one thread could swap in a pointer to a data structure after initializing it, and another thread could see the pointer write before it sees the structure initialized. <zacts>mark_weaver: so SXML could be useful for my goal? Namely, web bookmarks with tags... <rlb>mark_weaver: right, you'd need the correct platform-specific (or I suppose C11) primitives, or a mutex. <mark_weaver>zacts: you could do it in a lot of different ways, but sxml is a nice representation of XML to work with in scheme. <zacts>mark_weaver: how would I add a tagging feature to the sxml? <rlb>ACTION goes to see how close sxml is to clojure's xml representation... <mark_weaver>zacts: I'm sorry, I don't have time to walk you through this. <zacts>oh mark_weaver no it's fine! I just didn't know if it's an out of box sxml feature, or if I would need to implement it myself <zacts>anyway, I can look into it myself <mark_weaver>sxml is nothing more than a way to represent arbitrary XML documents as s-expressions. <mark_weaver>rlb: but the important point is that readers must synchronize as well, although on some platforms (e.g. Intel) the reader synchronization operation can sometimes become a no-op. <rlb>right, but a mutex should guarantee that, as should the other primitives (to be useful). <mark_weaver>e.g. the consume barrier can only become a no-op if there is "data dependency", as opposed to a control dependency, so depending on how the code comes out you might be okay or not. <rlb>i.e. if I call (compare-and-swap! atomic-ref old new), it should just DTRT. <mark_weaver>yes, a single global mutex would do the job, but it would also suck rocks for performance :-/ <rlb>right, but I'd assume that'd just be the fallback on platforms where we can't do better. <rlb>I thought I recalled some gcc (or something) extensions for example... <rlb>or as you say, a library <mark_weaver>these atomic objects should be opaque types that can only be read or written to using specific procedures that will perform the necessary synchronization. <rlb>That's what I'm saying ;> <mark_weaver>libatomic_ops is the only thing we can use that won't make us less portable than we already are. <rlb>i.e. compare-and-swap! for example would only work on an atomic-ref type which would be the "container" <mark_weaver>and it actually happens to be a pretty good set of primitives. <rlb>Anyway, not today's problem. For now I can just use a mutex or possibly an arbiter-based implementation. <rlb>Interesting, paredit behaves differently in scheme mode (started using it since the last time I was hacking in scheme very heavily). <mark_weaver>I guess it depends on various reformatting and sexp-movement operations that vary between editing modes. <sneek>stis was here Jul 09 at 08:35 pm UTC, saying: Look how it is done for python.. <rlb>It's not a big difference (and I'm still a novice wrt paredit), but every now and then it seems to unexpectedly insert a blank line after the current line.... or I'm "doing it wrong". <rlb>or maybe it's directly after the cursor - I haven't investigated, and just keep reflexively fixing it. <mark_weaver>one case where it inserts newlines is when typing ";" <mark_weaver>I definitely had to train myself to use different editing commands, to avoid commands like C-w that might create imbalanced parens, and instead use things like C-k that are modified by paredit. <mark_weaver>I still occasionally use C-w, but if so I'm careful to use sexp-moving operations to create the region. <rlb>Any preference between compare-and-swap! vs compare-and-set! flavors? <rlb>i.e. returning a boolean vs the value read? <rlb>and I guess the latter might be be named compare-and-set!? <rlb>Actually, nevermind - not going to abstract it that far right now. <amz3>I'm typing so slowly I'm working on the same two 5 line procedures for 1 hour or so <amz3>so my program does the following: take a pseudo scm file that use skribe reader syntax. It must end with a sxml that has a quasiquote like: `(p (:class "footer") [made with guile]) <amz3>skribe syntax adds :keywords and [quasiquote that don't eat space and support ,(unquoting)] <amz3>then the file evaled using something like (load) and turned into pure sxml <amz3>the advantage of this are: 1) skribe syntax easier than pure scheme, 2) I changed a bit the sxml syntax to be a bit simpler, maybe broken too <amz3>3) you can (use-module) in the pseudo sxml 4) you can configure the environment passed to the pseudo sxml file <amz3>I aim to create a template language based on it similar to django/ror <amz3>or simply chill doing scheme :)) <amz3>This is a rewrite of a previous code, a couple of hundred lines and now it's 50 sloc <rlb>What's the best (lightweight) way to include a unique id in the printer for a srfi-9 record? i.e. is there a "%p" equivalent? <rlb>Trying to remember syntax-rules - is it possible to define a local helper syntax inside a define-syntax? <rlb>i.e. avoid a top-level define-syntax for the helper? <mark_weaver>rlb: no, not with syntax-rules. but the helper can be private to the module, or else you can use syntax-case instead. <mark_weaver>another common hack is to include the helper in the same macro by passing a literal string as one of the initial arguments and matching based on that. <mark_weaver>but my recommendation would be to make a top-level helper macro that's private to the module <rlb>ok, thanks - that's what I'd done, and it's working, so I think I'll leave it alone ;> <rlb>mark_weaver: clojure has nil (which is really java null), and it's handled particularly in various places, i.e. <rlb>([coll x] [coll x & xs]) <rlb> conj[oin]. Returns a new collection with the xs <rlb> 'added'. (conj nil item) returns (item). The 'addition' may <rlb> happen at different 'places' depending on the concrete type. <rlb>For functions that we might want to share between guile and clojure, perhaps have the guile-side version without nil handling, and then have a clojure-side wrapper that adds it? <rlb>(Of course I might realize this is all irrelevant if/when I get a bit further...) <amz3>rlb: you work on a clojure lang for guile ? <rlb>amz3: maybe - too early to tell. <rlb>just poking around again <amz3>never tried clojure, it's quite active especially on clojurescript side <rlb>I've quite enjoyed working with it both on the jvm and (some) cljs, but there's still a fairly big gap implementation-wise. If it were to work out, I suspect this might fill a notable niche. <rlb>But no telling if I'll actually get anywhere significant yet. <rlb>Guile has some substantal strengths as compared to the other platforms. <amz3>realy I don't know how guile compares to other plateforms. What are its strengths? <rlb>Compared to jvm (and cljs). <rlb>clojure/jvm and clojurescript do have their strengths, but for example, the minimum startup time on my (not all that slow) laptop for clojure/jvm is ~1s <rlb>For guile it's 0.05s <rlb>Also guile has much better potential integration with C, and it's much friendlier wrt POSIX (the JVM only recently admitted symlinks are a thing, for example). <rlb>And there are *no* unix domain (filesystem) sockets <rlb>As compared to clojurescript, guile has real threads. <rlb>And of course guile has *scheme* ;> <amz3>I mean real thread with no GIL. That's what got me interested in Guile <amz3>Say, why not implement clojure feature in scheme directly? <rlb>If it were to work out, being able to work in both languages would be nice, as would the long considered emacs integration. <rlb>elisp/scheme/clojure <amz3>why not implement clojure feature in scheme, instead of building a frotend language <rlb>amz3: I imagine this will be a hybrid, if it works out, i.e. much of the interesting bits will be equally available to guile and clojure. <rlb>because I want both? ;> <amz3>last question, except immutability, what makes clojure a special lisp <rlb>It's perhaps easier with clojure than with some other languages since clojure really is a family of dialects rather than one language, and encourages close integration with the host platform. <amz3>(I hear clojuros like immutability a lot) <rlb>amz3: the biggest portable things are probably the carefully considered concurrency story and yes, the broad immutability/laziness. <rlb>On the non-portable front, it makes it vastly easier to deal with the jvm (i.e. you can generally write a given thing much more concisely in clojure than in java) <rlb>And one of the strengths of the JVM is (some of) its very large collection of libraries. <rlb>foo().bar().baz().bax()... becomes <rlb>make that "new foo()..." <rlb>hmm, that's not a great example, too trivial, but anyway... <rlb>(-> (foo.) .bar .baz .bax) <rlb>And really it would have been "LongTypeName foo = new LongTypeName()...." which you can omit in clj. <rlb>Also allows some very powerful things that you really can't even do in java, with java classes. <amz3>I read a bit about datalog it's popular in clojure <rlb>But right, portably, probably mostly concurrency (agents/refs/atoms/software-transactional-memory), laziness, and immutability. <rlb>It also has some handy syntaxes (some of which may be polarizing) <amz3>for me it looks like an improvement for the jvm not the larger lisp community <rlb>I've experienced too much suffering at the hands of POSIX threads not to appreciate the concurrency support. <_amz3_>I will have a look at the concurrency support of clojure then <_amz3_>datomic is fully immutable database, it's impressive what you can do, like going back in time. <rlb>Though I generally prefer reading to video, iirc there may be some good talks by Rich Hickey describing the concurrency support...