#clojure log - Jan 18 2011

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:11 mabes: ,(def foo (Foo. 4 5)) (.newInstance Foo)

0:11 clojurebot: DENIED

0:11 mabes: hrmm.. does clojurebot not like defrecord?

0:12 anyways, the above is not working for me. I get a java.lang.InstantiationException

0:12 tonyl: not def

0:12 mabes: oh

0:12 opps, wrong line of code

0:12 ,(defrecord Foo [x y]) (.newInstance Foo)

0:12 clojurebot: DENIED

0:13 mabes: anyways, that line errors out with a.lang.InstantiationException.. any ideas on how I can get a new instance of Foo using newInstance or similar? In my case I have a 'type' that I want to create a new instance of

0:14 tonyl: (Foo. 4 5)

0:14 mabes: rigth, but Foo could be any class in a var called type

0:15 tonyl: you can use (new Foo 4 5)

0:15 (new #'type 4 5)

0:17 I don't think I understood your question, is that what you meant?

0:18 mabes: ,(defrecord Foo [x y]) (let [type (class (Foo. 4 5))] (new #'type 3 2))

0:18 clojurebot: DENIED

0:19 mabes: yeah, although now I get "Unable to resolve classname: (var type)"

0:20 also, I don't seem to be able to init Foo with no args.. I thought defrecord allowed you to do that...

0:20 ,(defrecord Foo [x y]) (new Foo)

0:20 clojurebot: DENIED

0:20 mabes: sigh

0:22 ,(defrecord Foo [x y]) (seq (.getConstructors Foo))

0:22 clojurebot: DENIED

0:23 mabes: I thought defrecord gave you a constructor with no args, but that doesn't seem to be the case...

0:23 tonyl: it doesn't seem so

0:23 I am new to records too

0:23 maybe somebody else would step up

0:25 mabes: this SO post hits on what I'm wondering about: http://stackoverflow.com/questions/4520319/clojure-assigning-defrecord-fields-from-map

0:26 tonyl: thanks anyways, that was helpful

0:29 tonyl: maybe this might help (defmacro instantiate [klass values] `(new ~klass ~@values))

0:29 from this link http://stackoverflow.com/questions/4514196/how-to-make-a-record-from-a-sequence-of-values

0:41 amalloy: mabes: records have a constructor that takes one argument for each field

0:42 what would be the value of creating a record with fields missing? they're immutable anyway, and you lose any performance gain if you fill them up chunk-at-a-time

0:54 tomoj: not quite any, right?

0:57 huh, I thought keyword access on records was supposed to be really fast?

0:58 it looks slower even that hashmap access

1:15 amalloy: tomoj: it should be fast, yes

1:21 tomoj: amalloy: https://gist.github.com/5a4b5b4846b702f2266a

1:24 amalloy: tomoj: hiredman was trying to explain to me earlier today that the first time you call (:x some-rec) it looks up the .x element and caches it for faster access (as in your third test)

1:24 that doesn't seem to be happening here but my understanding is that it should be

1:24 tomoj: ah, hmm

1:25 does it depend on AOT, I wonder?

1:25 amalloy: tomoj: it's silly, i know, but what if you put a type-hint on foo? (:x ^Foo foo)?

1:25 tomoj: tried it

1:25 in both the let binding and at the callsite

8:08 shortlord: technomancy: how do you access the "rooms" ref in your Mire server? I have been trying to set up some simple server and run a repl on it, but I always end up in a different namespace than the server and so can't access any variables on the server through the client

9:02 Somelauw: Is there a difference with scheme when using reduce? I am trying (reduce cons () (range 5)) and it says it can't create ISEQ from Integer.

9:04 Oh, I see the parameters in the update function are reversed: (reduce (fn [x y] (cons y x)) (list) (range 5))

9:04 AWizzArd: Somelauw: conj

9:04 instead of cons

9:04 raek: yes. you can also use 'conj' here

9:04 AWizzArd: ,(reduce conj () (range 5))

9:04 clojurebot: (4 3 2 1 0)

9:05 AWizzArd: ,(reduce #(cons %2 %1) () (range 5))

9:05 clojurebot: (4 3 2 1 0)

9:06 Raynes: Is there any particular reason you're doing that in the first place?

9:07 Somelauw: I like to reverse lists in a geeky way.

9:07 AWizzArd: (:

9:09 shortlord: how can I change in a thread to another namespace? using (ns namespace-name) results in an error

9:09 Exception in thread "Thread-3" java.lang.RuntimeException: java.lang.IllegalStateException: Can't change/establish root binding of: *ns* with set

9:10 AWizzArd: shortlord: in-ns

9:11 But it is not likely that you really want to do that.

9:11 Perhaps you want to call a function in NS1 from a thread.

9:11 in that case you can (NS1/your-fn arg1 arg2)

9:14 shortlord: AWizzArd: well, the situation is this: I want to write a very simple remote repl, that lets me inspect the server. Just using the normal repl or read-string does not work, because these launch in the clojure.core namespace

9:15 I have written an execute function in the server namespace that executes an input string using load-string, but even calling servernamespace.core/execute still won't find the symbols in the server namespace

9:28 AWizzArd: do you have any idea how evaluating forms in the current namespace without switching to it could be done?

9:28 tomoj: ,(doc require)

9:28 clojurebot: "([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, ...

9:29 AWizzArd: shortlord: you most likely want, as tomoj indicated, require a ns.

9:31 shortlord: for example, when you have Clojure-Contrib in your classpath and do (require 'clojure.contrib.string) or even better (require '[clojure.contrib.string :as string]) then you can do (string/join ...)

9:34 raek: that still won't make 'foo' resolve to 'servernamespace/foo'

9:36 ,parse

9:36 clojurebot: java.lang.Exception: Unable to resolve symbol: parse in this context

9:36 raek: ,(binding [*ns* (the-ns 'clojure.xml)] parse)

9:36 clojurebot: java.lang.Exception: Unable to resolve symbol: parse in this context

9:37 raek: ,(require 'clojure.xml)

9:37 clojurebot: nil

9:37 raek: ,(binding [*ns* (the-ns 'clojure.xml)] parse)

9:37 clojurebot: java.lang.Exception: Unable to resolve symbol: parse in this context

9:37 AWizzArd: ,(ns-resolve 'clojure.xml 'parse)

9:37 clojurebot: #'clojure.xml/parse

9:38 raek: (binding [*ns* (the-ns 'clojure.xml)] (eval 'parse)) => #<xml$parse clojure.xml$parse@322bce>

9:39 AWizzArd: You can also call the result of (ns-resolve 'clojure.xml 'parse).

9:42 Somelauw: Also, what happened to foldright?

9:42 raek: yeah, (resolve 'parse) in that position will yield the same result too

9:43 there was a thread re foldright on the google group

9:43 AWizzArd: Somelauw: (reduce f (reverse coll))

9:44 I think vectors can be reversed in O(1)

9:44 Somelauw: Does reverse have exactly the same performance as reduceLeft?

9:44 fix: Does reverse have exactly the same performance as reduceRight?

9:45 raek: reverse will force all elements of the seq to be in memory at the same time

9:45 reduce will not

9:45 so reduce is more lazy-seq friendly

9:46 Somelauw: AWizzArd, so it won't actually reverse anything?

9:46 shortlord: raek, AWizzArd: thx a lot. it works with a *ns* rebinding :)

9:48 Somelauw: But would (reverseRight fun seq) perform faster than (reduce fun (reverse seq)) when used on linked lists?

9:49 Or consume less memory?

9:49 raek: shortlord: how is reverseRight defined?

9:50 also, reverse is always O(n). vectors have the rseq funcion, which is O(1).

9:50 ,(doc reverse)

9:50 clojurebot: "([coll]); Returns a seq of the items in coll in reverse order. Not lazy."

9:50 raek: ,(doc rseq)

9:50 clojurebot: "([rev]); Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order. If rev is empty returns nil"

9:51 raek: ehrm.. I meant Somelauw...

9:52 Somelauw: raek, I meant reduceRight (or foldRight)

9:54 raek: clojure has no reduceRight/foldRight

9:56 (reduce fun coll) = (reduce fun (seq coll)) would have the same performance characteristics as (reduce fun (rseq coll))

9:56 ...and memory characteristics

9:57 pdk`: grown ups are always reducing the fun

10:14 AWizzArd: raek: yes, rseq I meant, good point

10:53 LauJensen: fogus`: Hows Marginalia coming along ?

10:54 fogus`: LauJensen: I think trunk will fix your protocol doc problem. But I haven't tried it on your source yet.

10:54 LauJensen: trunk?

10:54 Raynes: fogus`: Get your mind out of the subversion gutter.

10:54 LauJensen: oh my - I was afraid that was what he meant

10:54 fogus`: doh! occupational hazard

10:55 Raynes: fogus`: doccupational hazard, more like.

10:55 LauJensen: fogus`: I just have one question http://images.nonexiste.net/irc/2008/10/13/git_two.jpg

10:55 * fogus` LOLs

10:58 raek: upcomming suport for extrating the dosctrings from defprotocol forms?

10:59 LauJensen: Hopefully - ClojureQL documentation looked very scarce seen through Marginalia

10:59 fogus`: raek: Yes. It always worked (defprotocol Foo "for this" (bar [this] "but not for this")

10:59 raek: ah, ok

11:00 I remember trying it and something did not work

11:00 fogus`: raek: We pushed the regex impl as far as possible and it broke us

11:00 LauJensen: fogus`: Feel free to test on CQL before you release :)

11:01 We have stuff like multiple arities in the protocol

11:02 fogus`: Understood

11:05 raek: is this allowed in regular mardown? "one `two<newline>three` four"

11:06 LauJensen: raek: You need two newlines for an actual newline I think

11:06 raek: but consulting the daring fireball

11:07 s/consulting/consult/

11:07 sexpbot: <LauJensen> raek: but consult the daring fireball

11:07 raek: I don't want a new paragraph. I just want to keep my lines less than 80 chars wide

11:08 Raynes: raek: If you need to newline in the middle of code, you probably don't want ``.

11:08 raek: so I use M-q in emacs, which sometimes splits up `two three` into two lines

11:08 single newline is like a space in non-github markdown

11:09 ;; Take a look at this arbitrary map: `{:a 1,

11:10 ;; :b 2}`. Blah blah

11:12 anyway, I have to fight emacs to not break those up, since marginalia does not currently handle this as I expected it

11:12 fogus`: raek: I always test Markdown at http://attacklab.net/showdown/

11:13 That page seems to do what you want.

11:13 raek: fogus`: thanks!

11:14 Raynes: I'm only somewhat well-versed in markdown of the pandoc variety.

11:14 fogus`: raek: Caveat being that there is no official standard and different parsers tend to do slightly different things

11:15 LauJensen: Is there some special syntax specific for Marginalia, I mean for doing examples or some such thng?

11:15 raek: fogus`: would it be a good idea to make marginalia handle ";; blah `foo\n;; bar` blah" in the same way as the parser you linked handles "blah `foo\nbar` blah"

11:16 fogus`: LauJensen: The only current extension that we have is the support for Latex and MathML equations

11:17 raek: Does it not handle it properly now?

11:18 raek: fogus`: no, it outputs "blah `foo bar` blah" rather than "blah <tt>foo bar</tt> blah"

11:18 shortlord: after I've put a core.jar file with java classes in it into a directory on the classpath, how can I import it in clojure? :import core.* does not work, neither does :import processing.core.* (the latter would be the correct line in eclipse after adding it to the build path)

11:19 tonyl: shortlord: you can only import classes

11:20 not classes inside packages

11:20 lpetit: ping ! "Lost in translations lpetit" looking for a little bit humanity, humility and sympathy

11:20 fogus`: raek: Maybe there is something that we can do, but if it's in the markdownj lib I'm not sure we'll get around to fixing that

11:21 Raynes: shortlord: To translate what tonyl just said to English, there is no way to import all of the classes in a package at the same time. You have to import the ones you want individually.

11:21 raek: fogus`: ok. I might look into it.

11:21 Raynes: (:import (processing.core SomeClass AnotherClass MoreClasses ...))

11:22 It may seem tedious at first, but readers of your code will thank you.

11:22 * fogus` reading http://matt.might.net/articles/compiling-up-to-lambda-calculus/

11:23 * Raynes considers writing a markdown parser in Clojure for giggles.

11:23 shortlord: Raynes: ah, that works! Thanks a lot :)

11:25 raek: fogus`: should I create an issue for this?

11:26 fogus`: Raynes: We wrote JoC in and extended Markdown. We didn't implement all of it in Clojure though, only the extended bits.

11:26 Raynes: fogus`: I'm using Pandoc's extended markdown for my book. It's pleasant.

11:26 fogus`: raek: Please. BTW, I think that Gruber wrote a reference Markdown parser that serves as the "standard"

11:28 * raek writes that down.

11:29 fogus`: Raynes: Looking forward to reading it. :-)

11:29 Raynes: :>

12:00 bhenry: why does every example i can find of ring-session use sandbar's wrap-stateful-session?

12:00 *ring's wrap-session rather

12:03 _na_ka_na_: hey guys which web server do you recommend for a Clojure web app in production to be run as a windows service

12:05 tomcat doesn't work nicely if I deploy my app as a Servlet

12:07 gives errors like: SEVERE: The web application [/] appears to have started a thread named [pool-2-thread-1] but has failed to stop it. This is very likely to create a memory leak.

12:16 Licenser: aloa

12:16 Scriptor: does anyone know if the jdk 7 is going to support tail calls? From the features list they only seem to have gone as far as dynamic invocation

12:16 Licenser: it got quiet in the channel or is it me?

12:17 Scriptor: it often gets quiet here

12:17 amalloy: Scriptor: i think the answer is no

12:17 Scriptor: dammit

12:50 gtrak: _na_ka_na_ application servers get fussy about threads, that's one of the reasons they exist, to manage all that for you

12:50 tonyl: why do vars have private meta and what is it for? just for the compiler?

13:10 amalloy: tonyl: it stops it from being imported when someone :refers your namespace

13:11 shortlord: is there any equivalent to map for functions that cause side effects?

13:12 dotimes seems to allow only a binding of 1 variable

13:12 Raynes: &(doseq [x [1 2 3]] (println x))

13:12 sexpbot: ⟹ 1 2 3 nil

13:12 shortlord: Raynes: but doseq would cause a different behaviour using 3 variables

13:13 amalloy: doseq is more like for than map, but yeah. if you prefer the map "style", you can ##(dorun (map println [1 2] [3 4]))

13:13 sexpbot: ⟹ 1 3 2 4 nil

13:14 amalloy: shortlord: is good?

13:15 shortlord: amalloy: have to test it, but that sounds like it could work

13:20 amalloy: yep, works. great, thx :)

14:10 LauJensen: Now thats a pretty blue line :|

14:10 http://www.google.com/trends?q=clojure%2Cphp%2Cruby%2Cscala&ctab=0&geo=all&date=all&sort=1

14:10 tonyl: amalloy: just came back. thanks for the explanation

14:11 nachtalp: also a nice example of text mining gone wrong: "Berlusconi: Gov't will last despite Ruby scandal"

14:11 tonyl: LauJensen: I don't see a blue line at all

14:11 LauJensen: tonyl: Thats right

14:12 nachtalp: Yea its hard to get around

14:12 nachtalp: LauJensen: most of the time i'm thankful it's not that easy to get right :)

14:14 amalloy: also entertaining is the sharp drop in searches for php around christmas every year, while the other languages stay about the same

14:14 nachtalp: :)

14:15 LauJensen: amalloy: You mean because their parents dont allow them to go online during the holidays?

14:15 nachtalp: this doesn't look a whole lot better either: http://www.google.com/trends?q=clojure,+scala&ctab=0&geo=all&date=all&sort=1

14:15 * amalloy declines to draw any meaningful conclusions

14:16 LauJensen: Yes, we must find a more level playingfield, like

14:16 http://www.google.com/trends?q=clojure%2C+algol&ctab=0&geo=all&date=all&sort=1

14:16 nachtalp: but i guess with scala there's also a lot of noise involved...

14:16 fdaoud: yeah, but did you notice it all has to do with Italian Opera? ;-)

14:17 amalloy: LauJensen: algol is surprisingly popular in finland

14:17 LauJensen: amalloy: The rule is: Whatever the Finns do with IT, respect it

14:17 I still remember in 96 when the rest of us barely could do shaded rotating 3d cube... then FutureCrew showed up at The Party ... ouch

14:27 Luyt_: hmmm, 'clorine' sounds noxious ;-)

14:28 pjstadig: at least its not clorjine or clorinjure or clojurinistic

14:28 amalloy: jlorine

14:28 Luyt_: cluorine, clotastic, clorgasm, cloffensive

14:29 clot

14:31 jjido: santa clos

14:53 gtrak: cloroform

15:19 ossareh: morning all

15:21 tonyl: afternoon ossareh

16:01 jweiss_: can someone suggest a good way to do this in emacs: I have a piece of code within a defn that I want to test, but it refers to a function argument, so I can't just C-x C-e it. Copying it to the repl doesn't work either bc it's in a different ns.

16:01 i want to bind the function argument to a value and evaluate the sexp

16:02 amalloy: jweiss_: kill the code segment, then yank it into a C-c C-e (let [arg foo] ...)?

16:02 hardly elegant, but...

16:05 raek: jweiss_: C-c M-p <ret> in the source buffer to change namespace of the repl to the one of the buffer

16:05 jweiss_: raek: aha

16:05 ok that is the direction i was going (manually)

16:05 raek: same as (in-ns 'the.name.space)

16:06 amalloy: raek: which reminds me, that doesn't work if the ns has any metadata

16:06 raek: jweiss_: github.com/technomancy/swank-clojure lists some really useful commands

16:07 amalloy: I usually enter the metadata as a docstring and an "attribute map"

16:07 amalloy: ie (ns ^{:doc "my awesome project"} awesome.project ...) causes a lot of things in slime to not work

16:07 raek: ,(doc ns)

16:07 clojurebot: "([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use...

16:07 raek: (ns foo.bar "foo docs" {:meta-key "meta val"})

16:08 amalloy: raek: agreed that's better but sometimes i have to work on libs someone wrote using the ^ style

16:11 raek: then I'd like to present a snipped technomancy showed me: (doto 'foo.bar require in-ns)

16:26 chouser: that's cute

16:28 bhenry: i always forget how to undef something.

16:28 to avoid restarting swank

16:28 chouser: ns-unmap, I think

16:30 bhenry: yep found it. thanks chouser

16:30 hiredman: there is always remove-ns

16:30 I wonder if swank should try that before compiling a file

16:30 bhenry: hiredman: depending on how remove-ns works you might be onto something

16:31 you can delete all your (:use) lines and recompile in swank and it won't complain.

16:36 S11001001: hiredman: dangling ns references elsewhere

16:36 and defeating defonce

16:44 hiredman: S11001001: *shrug*

16:47 puredanger: do protocols functions support varargs?

16:48 hiredman: nope

16:50 puredanger: hiredman: darn, oh well

16:52 * tonyl is pondering if PHP would benefit from Persistent Collections...

16:54 kumarshantanu: tonyl: PHP doesn't have threads

16:54 hiredman: php would just benefit from decent collections period

16:55 tonyl: yeah, that is what i was thinking, maybe a strong parallel programming system first

16:57 i like php arrays

16:57 kumarshantanu: is php6 going to address any of these?

16:57 tonyl: they were easy to use when i first starting programming

16:58 the only thing I know about php6 is unicode strings

17:02 kumarshantanu: I remember somebody prototyped PHP-like syntax for Clojure

17:02 tonyl: hiccup?

17:02 no i don't think is that one

17:02 kumarshantanu: Blah <? (println "hello") ?> blah

17:03 hiredman: tonyl: php arrays are pretty much garbage

17:04 and there is no proper associative datastructure

17:05 nickik: i just wrote a array library for VB

17:06 because VB proviedes nothing !!!!!

17:06 (VB classic)

17:07 The library is modle after clojure seq functions. The stuff is slow but it works and we don't really ned speed.

17:08 brehaut: nickik: i think every (decent) VB or VBA developer rolled their own datastructure classes

17:09 nickik: my firm didn't for 20 years :(

17:10 brehaut: i feel your pain

17:10 nickik: I didn't even have a function to print a array

17:11 we have ASP that VB-- you don't have optional arguments for example

17:11 we cant use any types and there are other restrictions too

17:11 brehaut: nickik: my last job involved maintaining a platform with around 2mil lines of VBA

17:12 nickik: oohh

17:13 kumarshantanu: https://github.com/Flamefork/fleet

17:13 nickik: brehaut: a big word macro :)

17:13 brehaut: hahaha

17:13 thankfully it wasnt that evil

17:14 nickik: brehaut: are there any good open source array librarys? I asked on Stackoverflow but knowbody answerd.

17:14 tonyl: kumarshantanu: I see, interesting

17:15 brehaut: nickik: not that i found

17:17 nickik: brehaut: im pretty happy with mine. Atm im implementing RecordSet to Array conversions but I not sure how to do it. You could make a 2d array but those are stupid to work with. I think my way will be a 1d array and then partition that thing.

17:17 brehaut: nickik: the thing i found most useful was implementing a bunch of iterators for building pipelines

17:19 nickik: brehaut: What do you meen be that. pipelines?

17:19 kumarshantanu: tonyl: if you can parse a file content at <? and ?> boundaries and re-write it as pure clojure code, then you easily eval it as (apply str ....) and probably that'll be something close to the PHP model

17:20 brehaut: nickik: are you familiar with unix ?

17:20 nickik: brehaut: ah ok

17:21 tonyl: wonder if it uses a the mod_proxy to parse the template through clojure then output the html

17:22 kumarshantanu: tonyl: fleet just evals them i guess

17:23 nickik: brehaut: could you explain a little bit how you did that and provide a use case? I'm having trouple imagening it.

17:23 privat chat maybe?

17:23 tonyl: kumarshantanu: i like your simple approach of html parsing

17:24 kumarshantanu: tonyl: posting questions about fleet on the group will likely get fleet author's attention, and hopefully accurate replies :)

17:25 tonyl: yeah, thanks for sharing kumarshantanu

17:26 amalloy: hiredman: php isn't my favorite, but its "arrays" are a perfectly fine associative structure. they're all k/v maps

17:26 array('data' => 10)

17:27 kumarshantanu: array(array("key" => 50) => 100)

17:28 amalloy: kumarshantanu: well yeah, the keys have to be strings or ints, which is gross for sure

17:28 so not a very spirited defense of php from me :)

17:28 zakwilson: Trying to improve PHP is like putting lipstick on a pig.

17:29 kumarshantanu: zakwilson: +1 (i use php at work)

17:29 zakwilson: It is so flawed, to its very core that you'd waste time doing anything but scrapping the whole thing.

17:30 amalloy: zakwilson: c'mon, so cliche. maybe it's more like making twinkies healthy by using whole grains

17:30 zakwilson: And the culture is fundamentally aligned against improving it. Ask them to do the Right Thing and they argue against it.

17:30 Whole grains would actually make them more healthy... it's more like organic twinkies.

17:31 hiredman: amalloy: they only allow strings or numbers as keys

17:31 amalloy: hiredman: yeah, see above where i give up on defending php

17:32 kumarshantanu: string and int can be unambiguously hash-keyed, maybe that's why

17:33 int is the straight index though, not a hash

17:35 hiredman: I would be surprised if php "arrays" did use any hashing

17:35 Testing safe.test.elasticsearch

17:35 FAIL in (test-rollover-play-dead-good-dog) (AFn.java:163)

17:35 with a sufficent shard size, split between two indices

17:35 whoops

17:35 wrong buffer, a thousand pardons

17:36 amalloy: hiredman: they do hash; lookup by key is O(1)

17:36 hiredman: amalloy: I bet

17:41 kumarshantanu: bye all

20:08 hiredman: ,(double 3663/2)

20:08 clojurebot: 1831.5

21:17 akhudek_: I've just experienced a StackOverflowError in the clojure compiler.

21:18 I understand this can be caused by recursive macros, although in this case, I can't see that happening.

21:18 Here is a stack trace of the problem, with two relevant functions: https://gist.github.com/785569

21:19 I'm at somewhat of a loss on how to track the problem down further.

21:23 tonyl: have you try running it without the macro

21:23 it seems that the macro doesn't need to be there

21:23 since all of its args are evaluated

21:23 still looking where that SOE might be happening, but that was just a thought

21:23 akhudek_: let me try that

21:31 yep, still happens without the update-in-meta macro

21:32 It must be something to do with the larger structure of the program, although the main loop is a recur loop, and I'm not seeing how a stack can be built up during it.

21:33 tonyl: it can if it is realized

21:34 but i don't think that can happen is there is no data to store but just computation

21:36 akhudek_: Well, it does store data as it goes. The context is that this is a backtracking theorem prover. I'm using delay to store a stack of backtrack points. That particular stack is implemented using a vector.

21:40 amalloy: akhudek_: yeah, this update-in-meta thing looks fine

21:42 and indeed update-in-meta by itself works fine. it has to be something in the calling context

21:43 akhudek_: hmm, ok, that helps, I think I may have found it.

21:43 Main loop has a pair of functions that call each other, this is likely the source of the deepening stack.

21:48 dnolen: akhudek_: what are you using the theorem prover for?

21:48 akhudek_: query rewriting

21:49 we'll be released it as open source at some point, assuming we can iron out all the research issues

21:49 dnolen: akhudek_: for databases?

21:50 akhudek_: initially, yes, although it should actually be flexible enough to do compilation in other contexts too

21:51 dnolen: akhudek_: interesting. I've been messing around with backtracking a unification a lot lately, been writing my own implementation of a logic engine based on miniKanren (a Prolog variation)

21:52 akhudek_: the way I way avoided stack overflow in my project was to express mutually recursive functions as lazy sequences.

21:53 akhudek_: hm, kanren looks pretty interesting

21:53 we decided to roll our own prover because we need a lot of alternative proofs

21:53 and alternate proofs in a specific way

21:54 each proof corresponds to some translation of one fol sentence to another

21:55 dnolen: akhudek_: https://github.com/swannodette/logos, is my project. would love to see how you're tackling similar problems when you guys open it up.

22:00 akhudek_: Neat, I'll take a look at it. Briefly looking at your examples suggest that your overall structure is very different than ours.

22:02 I'm not sure when we'll be putting code up, although we may have a paper out sometime this year.

22:03 dnolen: akhudek_: looking forward to that. any particular reason you picked Clojure for your research?

22:04 akhudek_: We felt it would help us prototype things quickly.

22:05 In particular, we make extremely heavy use of clojures versioning data structures both for backtracking and simplicity of implementation.

22:06 dnolen: akhudek_: yeah, for backtracking it's a beautiful match, I'm using PersistentHashMaps to hold the logic var bindings.

22:08 akhudek_: Same design here. We also use it for our tableau structure. When we extend a branch, we simply copy the entire world and make the necessary change in the new one.

22:09 Although that may come back to haunt us, since one technique we are considering requires going back and modifying the tableau in the middle of the tree.

22:09 That is now difficult since we'd have to somehow propagate the changes down the branches.

22:13 cobol_expert: is there a way to create a defrecord instance with named arguments?

22:13 useful for big arg lists

22:13 akhudek_: cobol_expert: no, you'll have to roll a macro for it

22:14 cobol_expert: thnx, good idea

22:14 akhudek_: I think there may be a few on the web if you look

22:14 dnolen: akhudek_: cobol_expert: or a function, in 1.2.0 you can have keyword args to functions.

22:16 cobol_expert: actually, i'm not sure what good either of those would do

22:16 if you have a (defrecord Point [x y])

22:16 dnolen: cobol_expert: you write a constructor fn.

22:16 cobol_expert: and want something like (Point. :x 1 :y 2)

22:17 you'd have to throw away the argument names

22:17 dnolen: (defn make-point [& rest] ...)

22:17 (make-point :x 1 :y 2)

22:18 cobol_expert: you'll want to do something like that anyway, as otherwise consumers will need to import the Java class that is your defrecord.

22:19 akhudek_: to elaborate, something like https://gist.github.com/785627

22:19 I keep forgetting keyword args were introduced.

22:20 cobol_expert: hm, i'm a little behind on destructuring, so i can't tell what that does

22:20 actually a lot behind

22:21 amalloy: akhudek_: they weren't, really. what was introduced was the ability to destructure maps in a & arg

22:21 cobol_expert: i see, so the x,y in the gist example just map to the appropriate fields

22:21 akhudek_: cobol_expert: the & means that what follows is a collection of the remaining arguements

22:21 cobol_expert: er.. so to speak

22:22 akhudek_: in that case, all the arguments since I specified none

22:22 the brackets destructure that collection as a map

22:22 cobol_expert: i got that part

22:22 akhudek_: defining keys x and y

22:22 the or is the default parameters

22:23 cobol_expert: ah, cool

22:23 thx! i'll play around with that a bit

22:27 amalloy: cobol_expert: you might also be interested in defrecord2, which automatically does this stuff

22:27 $google defrecord2

22:27 sexpbot: First out of 12 results is: david-mcneil/defrecord2 - GitHub

22:27 https://github.com/david-mcneil/defrecord2

22:30 cobol_expert: thanks, that looks useful

22:30 amalloy: (standard disclaimers apply: i haven't used it, don't know if that's the canonical repository, etc etc)

23:01 dnolen: nice, 1.5X speed boost for logos.minikanren unification. protocols FTW.

Logging service provided by n01se.net