#clojure log - Jul 15 2015

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

0:16 mercwithamouth: does anyone have an example of connecting to postgres with clojure.java.jdbc

0:16 scratch that =P

0:18 actually..examples are welcome

0:19 i'm using luminus and the sample project but trying to figure out how to make it work with postgres...which i'm also new to

0:32 this is what i'm being thrown https://gist.github.com/anonymous/c4f85ad9f3a8792bf846

0:39 oooh

0:40 profiles.clj =P

1:12 anyone ever gotten .DS_Store' does not appear to be a valid migration ?

1:33 noidi: mercwithamouth, that's a file generated by OS X's finder https://en.wikipedia.org/wiki/.DS_Store

1:35 I guess your migration library expects every file in a particular directory to be a migration

1:38 mercwithamouth: noidi: yeah i just fixed it a few secs ago. i goofed and manually tried to create a migration file opposed to running 'lein migratus create ...' apparently there's some more stuff going on in the background

1:38 didn't make any sense =P

6:02 Pupeno: I should use the version 0.1.0-SNAPSHOT should be while developing, then, for release, I should switch that to 0.1.0 and then, when starting developing 0.2.0-SNAPSHOT?

8:24 lodin_: rs0: I went with resource, thanks.

9:53 xificurC: hi, what does one use to build a GUI nowadays? I played around with seesaw quite a while ago, is it still used? The last github commit is from Feb. Any alternatives one can recommend?

11:27 justin_smith: xificurC: I think there's some stuff for javaFX, can't remember any library names

11:28 and figwheel + react with cljs makes a great platform for developing browser based apps, if that's an option

11:34 xificurC: justin_smith: thanks, might check that out

11:42 tmtwd: what is the command in cider to pull in a function in nrepl without having to call (load-file)?

11:44 justin_smith: tmtwd: should be something like cider-eval-defun with a default binding that's something like Control-Alt-x

11:44 tmtwd: justin_smith, cool

11:44 justin_smith: will work with the cursor anywhere inside the form

11:53 csd_: Hi -- what are thoughts on using :pre assertions for type checking? I.e. that an arg is an instance of a certain class

11:56 justin_smith: csd_: better to check that it implements some protocol or interface

11:56 but sure

11:56 also look into prismatic/schema which has it's own version of defn that does type checking

11:57 csd_: but inside a :pre, or inside the code body?

11:57 like i'm wondering whether its better to throw an exception, or to violate the assertion

11:58 justin_smith: I'd use :pre for things that would be dev errors, (since assertions can be turned off as a runtim optimization), maybe just have regular condition checks and throw exceptions for runtime irregularities that would not be caused by bad code

11:58 :pre creates assertions

11:59 csd_: like, thinking in terms of contracts, my function should only take an instance of class Foo, and from that perspective an assertion makes sense

11:59 justin_smith: right, breaking that would be a code error, not a runtime condition

12:00 but once again, good clojure code should require some protocol or interface, not some class

12:01 csd_: justin_smith: the java object in question doesn't rely on a unique interface

12:01 should i in that case create a protocol?

12:01 justin_smith: csd_: oh, if it's some specific java object that's up to you

12:02 csd_: yeah its a custom business object. what did you have in mind?

12:02 justin_smith: unless of course it implements some interface, but you shouldn't break your back to fix someone else's bad design, sure

12:03 if you wanted to be extra proper you could make a protocol that abstracts the object and extend it for that object and rest knowing you could be flexible even if the original business object isn't, but really that's probably only marginally useful

12:03 csd_: the advice about coding to protocols/interfaces is more applicable when designing something new

12:03 csd_: yeah

12:03 ok

12:07 justin_smith: unrelated other question for you. what do you think about defining fn's as private and then unit testing them by doing something like (def the-fn #'my.ns/the-fn) ?

12:07 justin_smith: csd_: I'm not religious about test coverage, and usually I avoid testing anything that isn't public actually. But I'm probably doing it wrong.

12:28 tmtwd: [org.postgresql/postgresql "9.4-1201-jdbc41"] how would I require this dep in a core.clj file for example?

12:28 I tried [postgresql :as post] but it did not work

12:28 justin_smith: tmtwd: there is no relationship between package names and namespaces provided

12:29 tmtwd: oh

12:29 justin_smith: tmtwd: it defines something like jdbc-postgresql-adaptor that you can use with clojure.java.jdbc

12:29 but your code would almost all reference functions from c.j.jdbc itself

12:29 tmtwd: so I would require jdbc?

12:30 like [clojure.java.jdbc :as sql] ?

12:30 justin_smith: right

12:30 tmtwd: but how would I specify that it is for postgres and not mysql for example?

12:31 justin_smith: and I forget the exact mechanism, but somehow jdbc figures out that you are accessing postgres, and it loads the right adaptor for you

12:31 based on the connection? brb have to do morning standup

12:32 sobel: is there a preferred lib for hiding file url details? i want to get a stream from a local, sftp, or ftp URL

12:51 tmtwd: (defquery "createtables.sql" {:connection db-spec-post}) why is this a bad query for yesql?

12:53 justin_smith: sobel: as far as jvm is concerned, sftp and ftp accessed things are not and cannot be instances of File

12:53 sobel: but you could use a weaker and more abstract concept (like InputStream)

12:55 sobel: I should qualify that. I suspect they can't be File, but there may be a way to do it I don't know of.

12:55 tmtwd: http://pastebin.com/3h9BwtR2 I'm trying to create a db connections and create a db like this, but I'm getting the error that a persistent array cannot be cast to a String

12:55 with yesql

12:56 justin_smith: tmtwd: you are missing the name argument to defquery

12:56 so it things the hash-map (PersistentArrayMap) is supposed to be the file string

12:57 tmtwd: perhaps you meant to use defqueries

12:58 tmtwd: oh I seeee...

12:58 I thought defqueries and defquery did the same thing

14:24 blake_: Welp. I found the source of my problem. I cannot deploy to Wildfly if I don't have ring-jetty-adapter as a dependency.

14:27 justin_smith: wait wat?

14:27 that's super weird

14:32 blake_: It doesn't comport with my understanding of things either.

14:32 jcrossley3: blake_: i concur with justin_smith :)

14:32 blake_: Yet if I have ring-jetty-adapter in my project.clj, the project deploys. If I don't, it does not.

14:33 justin_smith: blake_: does your "wildfly deploy" exist of some construction paper and crayons that say "SeRver" and really it just runs your jar as a standalone?

14:33 blake_: Is it picking up java.servlet with that? I note that I tried all combinations: with servlet, with jetty, with neither.

14:33 justin_smith: lol...I dunno...how would I tell?

14:34 (That is CERTAINLY within the realm of possibility, I should say.)

14:34 justin_smith: because a container should not need the jetty-adapter, the jetty-adapter is for when you don't have a container

14:34 "my car only works when I also use a bicycle"

14:35 jcrossley3: yeah, i'm guessing it's pulling in another dep you need. what does 'lein deps :tree' say?

14:35 blake_: Well, maybe that's why I could get it to run locally (after taking out SSL). I thought it was a Widlfly 9 thing but that didn't hold up.

14:35 justin_smith: jcrossley3: oh, that's much more likely than construction paper and crayons

14:36 blake_: rin-jetty pulls in jetty-server, javax.servlet-api (3.1 not 2.5 like I had formerly specified), jetty-http, jetty-util and jetty-io.

14:38 jcrossley3: blake_: none of those with 'jetty' in the name should matter to wildfly, and i would've thought javax libs would already be in the classpath, but maybe not

14:38 and if that's the problem, there should be some pertinent stack trace in server.log

14:39 blake_: jcrossley3: Well, yeah, there were complaints about javax.servlet. But I also got those when it worked. So.

14:39 Why don't I need jetty to run using "lein ring server" locally?

14:40 jcrossley3: you do

14:43 blake_: Hmmm. My whole development process has been code, lein ring server, more code, etc. All without explicitly pulling in jetty. That's how the problem arose: I removed jetty at one point and deployments to Wildfly stopped working.

14:43 Cached?

14:43 justin_smith: blake_: the lein ring plugin should be pulling in the jetty dep

14:44 blake_: so my theory is that you were relying on jetty (via lein ring) and coincidentially there is some transitive dep of the jetty adapter that wildfly actually needs

14:44 so when you add an explicit jetty-adapter dep, that causes the one thing you need (plus a bunch of extra cruft) to deploy

14:45 hiredman: lein ring server uses the lein-ring plugin, which due to this that and the other implicitly adds dependencies on various bits of ring (including ring-jetty, and by extension jetty) when running its tasks, such as lein ring server

14:45 jcrossley3: blake_: lein deps :plugin-tree

14:46 hiredman: plugin-tree likely only works on the transitive dependencies of plugins

14:46 blake_: Hmmm. :plugin-tree shows leinjacker, some clojure.core stuff and data.xml.

14:46 hiredman: of course lein plugins can also throw random stuff in to the projects dependencies while running tasks

14:46 jcrossley3: ah

14:47 hiredman: which is almost certainly how lein-ring works, as do several others (like cljsbuild)

14:47 blake_: So...ring-jetty gets pulled in on the sly, perhaps?

14:48 hiredman: it depends what you mean by on the sly

14:49 blake_: Well, without me having to explicitly state it.

14:49 hiredman: and only for certain things

14:49 how are you packaging this project?

14:49 blake_: So, the only thing I can see ring-jetty pulling in that might be needed for Wildfly is java.servlet.

14:49 lein ring uberwar

14:50 csd_: I want to test a value coming over an async channel. How can I run this value through clojure.test?

14:50 hiredman: right, that should get you ring-servlet, which should get you java.servlet

14:51 blake_: hiredman: But wait, wouldn't that mean I =don't= need the java.servlet pulled in by ring?

14:51 hiredman: https://github.com/ring-clojure/ring/blob/master/ring-servlet/project.clj well actually ring-servlet expects java.servlet to be provided, and since I've never looked in to his before, but have used ring uberwar, it must mean other servlet containers do provide it

14:51 csd_: Only thing I can think of is to do the deftest inside the go loop

14:51 hiredman: blake_: for whatever reason, wildfly must not provide it

14:52 (how that is possible, I have no idea)

14:52 blake_: I also had javax.servlet specified! I mean, tried with java.xservlet/servlet-api specified, and no ring-jetty-adapter and it failed.

14:53 justin_smith: csd_: what about a blocking read of a channel in a test but outside the go loop? the test should wait for the read to complete before exiting

14:53 blake_: But with ring-jetty-adapter and no javax.servlet, it worked.

14:53 hiredman: blake_: what do you mean by failed?

14:53 blake_: (That's where I am right now, actually, trying to figure out how to get rid of ring-jetty-adapter.)

14:53 hiredman: was there an error or some exception?

14:53 csd_: justin_smith: but a go block cant ever return anything, can it?

14:54 justin_smith: csd_: go blocks return a channel that will transmit the final value from the go block

14:54 you can block on reading that channel

14:54 csd_: oh never realized that

14:54 blake_: hiredman: Oh, right, sorry. What happens is that it deploys but then when you hit it, the 8443 redirect returns nothing or an error.

14:54 justin_smith: also, if you need more flexibility, you can pass a channel into the go block, then do a blocking read on that channel, arranging to eventually write to the channel in the go block

14:55 hiredman: what does the log say?

14:55 justin_smith: csd_: but the default channel returned by the go block is totally what you should use

14:55 blake_: hiredman: The log doesn't report any errors. Or anything. I get some warnings in deployment but nothing when it's running.

14:55 hiredman: and what do you mean by nothing or an error, those are different things

14:55 csd_: justin_smith: what would the blocking read you're referring to look like? just a <!!?

14:55 hiredman: what warnings do you get in dpeloyment?

14:56 justin_smith: csd_: yup

14:56 csd_: it will prevent the test from returning until the go loop writes to its result channel

14:57 and you can also use the value that <!! returns, obvs.

14:57 csd_: and then juse use an alt with the other channel and (timeout)

14:57 just*

14:57 justin_smith: sure, if you need that logic, that makes sense

14:57 csd_: thank you

14:58 blake_: hiredman: Not installing org.eclipse.jetty.continuation, Deployment contains CDI annotations but no bean archive.

14:59 hiredman: my wild guess, not supported by any evidence at all is wildfly has a different version of javax.servlet, then the one you explicitly spec'd with your servlet dependency, or the one you implicitly get from lein-ring

15:00 if that is the case it may be tricky to fix

15:00 blake_: hiredman: It's better than anything I got. I need to see if I can get it working without the ring jetty.

15:01 I also think maybe more than one thing is going on here.

15:04 The "no bean archive" doesn't matter, right?

15:25 I've broken it again. The deployment is successful but I get an exception "Attempting to call unbound fn: #'myapp.servlet/service-method". I think that might be progress.

15:28 *looks at chat logs, sees exact same error message from 6 days ago...*

15:32 TimMc: sobel: You can probably use URI for handling different data sources.

16:02 jcrossley3: blake_: are you saying that with those jetty deps, the 8443 redirect works in wildfly? because that sounds crazy. :)

16:02 blake_: jcrossley3: Well, yeah. That's the way it's been running for months.

16:03 jcrossley3: blake_: without an https-listener configured in wildfly, i respectfully don't believe you

16:04 blake_: jcrossley3: There may well be an https-listener configured in wildfly. (In production. I've got local problems and I just have OOTB wildfly.)

16:05 jcrossley3: blake_: until you know exactly what you have in production, and can replicate it locally, you're just flailing

16:06 blake_: jcrossley3: It's a common situation, unfortunately. They do things in production and keep that from us for "security".

16:06 jcrossley3: blake_: so you may in fact have things correct in your app, but to replicate the behavior in production locally, you'll need to add an https-listener to your OOTB wildfly

16:07 blake_: jcrossley3: Yeah, that's probably my next step.

16:08 jcrossley3: blake_: and for your purposes, you may not even care about https (other than the redirect occurring). it may be simplest to just remove the security-constraint locally

16:10 blake_: jcrossley3: I've done that. The problem for me is that I can't go to deployment and say "It works without security."

16:14 jcrossley3: blake_: you should at least confirm that the https request is hitting wildfly in production, i.e. no reverse proxy, because if it's not, then you absolutely can say that

16:15 blake_: jcrossley3: If I can nail down the problem exactly then, yeah.

16:23 csd_: Maybe someone can understand this behavior. `scheduler.clj` has quartzite boilerplate and defines a simple job. core_test.clj kills any running scheduler, starts the scheduler, and schedules the job, and then listens over an async channel for whether the job was successful. I see that when I make a change to the scheduler file and it refreshes, the test will always fail, but then after i edit the test file, it will succeed again.

16:23 Any idea what might be going on?

16:23 i think this has to be due to the test-refresh code

16:24 justin_smith: top level channel definition that is getting redefined?

16:24 blkcat: win 32

16:24 oops

16:24 csd_: justin_smith: the channel is being redefined, but its also getting passed to the new job

16:25 justin_smith: hmm

16:25 csd_: it seems like the job never even runs

16:26 justin_smith: csd_: I'd be tempted to defonce an atom holding a vector, then change the job definition so that it always conj's a new timestamp to the end

16:26 the contents might end up being informative

16:29 gfredericks: ~defonce is a temptation

16:29 clojurebot: Ok.

16:39 justin_smith: gfredericks:

16:40 it's my sloppy debugging style

16:40 so it does feel like a temptation, or crutch

16:41 gfredericks: oh if it's just debugging then do whatever you want

16:41 my favorite is using (def ...) inside a function

16:41 justin_smith: gfredericks: that'll be my alibi when I murder Donald Trump

16:41 "I was debugging my code, see"

16:42 gfredericks: ~justin_smith is a political debugger

16:42 clojurebot: 'Sea, mhuise.

16:42 justin_smith: trump dies, code works, you can't explain that

16:44 csd_: justin_smith: sorry, colleague grabbed me. it's gotta be directly related to how test-refresh reloads code

16:49 blake_: Gonna be yoooge.

16:52 atomi: yeah

17:10 lgas: Hi. Can anyone point me to a good library project that's written in 1.7 and uses reader conditionals to provide Clojure and ClojureScript versions that shows how to set up a project.clj appropriately?

17:11 That is, so that it generates a jar that can be referenced from a clojure or clojurescript project.

17:12 justin_smith: lgas: here's a project that works in clj and cljs https://github.com/littlebird/conduit

17:12 I have been working on it lately (it's an abstraction for passing messages between a client and server)

17:13 lgas: as you'll see, there is not cljc setup in the project.clj at all, just a list of deps

17:13 lgas: Yeah, so everything else just works with the defaults?

17:13 justin_smith: lgas: yes, it just works

17:13 lgas: Hmmm interesting

17:14 justin_smith: as compared to eg. cljx

17:14 because cljc is handled on a language level, by clojure.core itself, so there is no tooling setup needed to make it work at all

17:14 other than using a recent enough clojure of course

17:14 lgas: right

17:16 justin_smith: other than certain tools that need fixing on the implementation level (eg. eastwood), but that's not a config thing at all

17:17 Bronsa: justin_smith: i might be wrong but I think eastwood can't really work with cljc until lein starts using 1.7 by default?

17:17 justin_smith: Bronsa: yeah, I don't think it's strictly eastwood's fault, it's just that the tooling doesn't enumerate cljc files as interesting yet, at some level

17:18 so eastwood is an example of something that doesn't work with cljc yet, is all

17:18 as is lein test

17:18 Bronsa: oh no nevermind. eastwood actually uses tools.reader

17:18 lgas: Yeah I nuked all the cruft I had in my project.clj and just left the deps and it looks like it's working. Awesome. Thanks!

17:19 justin_smith: lgas: I wish the answer was always as simple as "delete all of it and it will work"

17:19 LOL

17:19 lgas: no kidding

17:32 justin_smith: Bronsa: the issue with eastwood is just the part that figures out which files it should be linting, right?

17:34 Bronsa: justin_smith: and the fact that it uses a version of tools.reader that doesn't support reader conditionals

17:34 justin_smith: ahh, so it's deeper than that

17:34 interesting

17:35 Bronsa: justin_smith: yeah needs updated tools.reader and tools.namespace deps

17:35 justin_smith: Bronsa: I keep forgetting tools.reader is not part of core

17:35 Bronsa: justin_smith: it's entirely possible that andyf already updated them btw

17:35 might just need a release

17:36 justin_smith: Bronsa: most recent commits are "small typo in readme" and "mention in readme that 1.7 cljc files are not linted yet"

17:37 Bronsa: oh well then

18:45 weebz: I'm wondering, is there a way to start a secure nREPL on a server so only I can connect to it? I'm having trouble finding anything related to this

18:46 arrdem: weebz: it is possible to tell nrepl to bind to a port or address that's only locally exposed

18:46 Surgo: you could use the box's firewall to limit incoming connections

18:46 and just bind to 0.0.0.0

18:46 arrdem: or you could bind to localhost.

18:46 but there's nothing I know of that's an auth layer for nREPL

18:47 Surgo: I figured from the question that he wanted to connect remotely

18:47 weebz: Surgo: yes, start the nREPL on my remote server and then connect from my laptop at home

18:47 saimoon44: Hi all, I was wondering is there a way to provide to not use the default template structure of a leiningen project? I want my file containing the main function to be on the same level as the project.clj file. is is possible? Thanks a lot!

18:48 Surgo: I don't know of any auth either but there's some stuff that's on a slightly lower level you could use. You could bind to 0.0.0.0 and use iptables to restrict. Or you could bind to localhost and use a ssh tunnel, or netcat to tie together some connections

18:48 ssh tunnel is probably the most secure way :p

18:49 http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html

18:50 justin_smith: Surgo: by default nrepl won't accept connections from hosts other than localhost

18:50 and yeah, if you need a remote connection, don't do it without a tunnel

18:50 even the localhost thing is a privelege escalation waiting to happen :P

18:51 saimoon44: :src-paths "." but this is a terrible idea, still, because top level namespaces are terrible

18:52 so you should still have some directory structure nesting unless you are evil

18:53 sorry, that's :src-paths ["."]

18:53 saimoon44: justin_smith: oh thanks :) How terrible are they?

18:54 justin_smith: saimoon44: I'm being a bit hyperbolic of course, but don't use top level namespaces for anything that you would expect someone else to use

18:54 saimoon44: also, consider the security implications - if your various paths are inside the top level dir, you can have things in your repo that never end up in a built jar

18:55 saimoon44: if the top level dir is the root of the source path, then all files in your repo will end up in the jar, because they are all on that path

18:55 which could easily have unexpected consequences

18:55 saimoon44: justin_smith: all right, I will look into that, thanks a lot for all the details :)

19:13 tmtwd: can I use figwheel or something similar for use on server side (clj) code?

19:15 justin_smith: tmtwd: ring has wrap-reload which will reload source files when requests come in

19:16 tmtwd: justin_smith, thanks :) I wanted it so I don't have to press f5, but I think I will have to do it with websockets

19:16 justin_smith: I think there are more general auto-refreshing tools too, maybe even some functionality in clojure.tools.namespace

19:16 oh, with websockets ring auto-reload won't help yeah

19:17 but then again, with websockets you wouldn't want to disconnect all your socket connections when you change your code either, so you have to be picky about your reloading (or design things so reloading doesn't break them)

19:51 lodin_: How does future-cancel work? Where can the code be interrupted? If I for instance write to a file in a future and cancel the future, is it possible to end up with half a file?

19:52 arrdem: Using futures for side effects is probably a bad idea... futures as a mechanism are designed for expressing value computations which can occur in parallel.

20:00 lodin_: arrdem: OK. What do you use when you have a couple of concurrent operations with side effects that each return a value when done?

20:00 core.async?

20:00 clojurebot: core.async is 100% imperative

20:02 arrdem: lodin_: futues would work here, I'm just concerned that you're thinking about them getting caceled somehow.

20:02 damnit Bronsa is probably asleep...

20:03 lodin_: arrdem: I'm specifically thinking that canceling would be bad, but I wonder because it could be good to be able to have any waiting derefs return nil immediately.

20:04 arrdem: lodin_: so if you cancel a future, it will return nil but if the process computing its value has started it will not be killed.

20:05 at least that seems to be the behavior.

20:06 amalloy: arrdem: if you cancel a future, an effort is made to stop the process that was computing its value, but there are no guarantees

20:07 lodin_: arrdem: This is what I'm wondering. I haven't found any documentation about this. I think that if you have a Thread/sleep in there, it will listen for interruptions and the thread will be stopped.

20:18 saimoon44: Is there any way to pass options to leiningen from the command line? Like starting a repl with options that you would provide inside project.clj usually (like init-ns) or a new user profile, etc. ?

20:19 arrdem: saimoon44: the :injections keyword is a vector of unquoted code that will get evaluated in the user ns

20:20 pydave6367: Rookie question: say I have two collections [:a :b :c] [1 2 3] and I want to get a list of maps out of them: [{:a 1} {:b 2} {:c 3}]. Is there an easy/idiomatic way to do that?

20:20 kristof: arrdem: Sounds invasive.

20:21 arrdem: pydave6367: (map #(assoc nil %1 %2) keyvec valvec)

20:21 saimoon44: arrdem: but can you provide this on the command line? Or do you have to write into a file anytime you want to pass some different args?

20:22 pydave6367: arrdem: Thank you so much! Been wrestling with that one for a while!

20:23 arrdem: saimoon44: you can set that in the project.clj, alternatively you can write a user.clj file. If you want to manually invoke the Clojure jar I've seen a way to add an expression to be evaluated at the command line lemme dic for it.

20:24 lodin_: pydave6367, arrdem: Or (map hash-map keyvec valvec).

20:25 noncom|2: ,(keyword "heeeeeey that's rather cool!")

20:25 clojurebot: :heeeeeey that's rather cool!

20:25 saimoon44: arrdem: yeah I have heard of this user.clj file thing, it is still a file with conventional path I guess, is there any way to provide from the command line a specific file to be read to overrride it?

20:26 arrdem: saimoon44: no. clojure.core is hard wired to read user.clj if it exists

20:26 noncom|2: ,(symbol ":so, generally isn't that really wonderful::::")

20:26 clojurebot: :so, generally isn't that really wonderful::::

20:26 lodin_: (Or maybe array-map even since it's small.)

20:26 kaiyin: is there way to autocomplete file paths in cursive? in vim it's c-x c-f.

20:28 saimoon44: oh this is clojure thing? I would have thought this was coming from leiningen

20:32 Ok, well thanks arrdem, too bad that nothing can be provided to override repl options and such from the command line

20:36 pydave6367: lodin_: That's nice. I totally missed that. Thank you!

20:46 danielpcox: does anyone know what it means if you get this exception while using proxy? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core_proxy.clj#L24 I was trying to make a proxy object of a Scala abstract class, and I got "Incompatible return types".

21:27 I found an example in the standard scala libs:

21:27 (import scala.collection.immutable.StringOps)

21:27 => scala.collection.immutable.StringOps

21:27 (proxy [StringOps] [])

21:27 Exception Incompatible return types clojure.core/most-specific (core_proxy.clj:23)

21:34 lvh: I'm getting a weird compilation error: java.lang.ClassNotFoundException: taoensso.sente, compiling:(taoensso/sente.clj:1144:5)

21:34 I don't understand what it means for the class not to be found while compiling the clj file itself?

21:35 Here's the full stacktrace, but it doesn't really seem to help: https://gist.github.com/lvh/1eace2ad8963f12212cf

21:35 gfredericks: it probably doesn't mean that there is supposed to be such a class

21:36 (like if everything were working correctly)

21:36 it's probably clojure misinterpreting a symbol like taoensso.sente/foo for some reason

21:39 lvh: gfredericks: Huh, okay. How do I debug that? I think I know which ns is causing it, but I can't figure out what it's doing that the compiler doesn't like.

21:41 gfredericks: I think if you try to use a fully qualified symbol w/o requiring the ns you'd get that msg

21:41 ,taoensso.symbol/foo

21:41 clojurebot: #error {\n :cause "taoensso.symbol"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: taoensso.symbol, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.ClassNotFoundException\n :message "taoensso.symbol"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :tra...

21:41 gfredericks: ^ yep

21:42 might be other ways to get it, I don't know

21:42 lvh: hm

21:44 hiredman: lvh: the name of a namespace is not bound to anything

21:44 tmtwd: do lispers dislike yesql?

21:44 hiredman: ,*ns*

21:44 clojurebot: #object[clojure.lang.Namespace 0x627ae8af "sandbox"]

21:44 hiredman: ,sandbox

21:44 clojurebot: #error {\n :cause "Unable to resolve symbol: sandbox in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: sandbox in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: sandbox i...

21:44 hiredman: ^-

21:45 but most namespace names contain dots, with the clojure compiler uses as a heuristic to decide if it should try and treat a name as a class reference

21:46 so somewhere in the sente.clj (most likely at the line and column given in the error) you will have the symbol taoensso.sente

21:46 (or you have some badly written macro generating it)

21:47 lvh: hiredman: OK, but the file it's attempting to compile just requires [taoensso.sente :as sente] and only uses sente/whatever, so, hm

21:47 hiredman: you are looking in the wrong file

21:47 lvh: the thing I get the error about is from compiling *upstream*'s sente.clj

21:47 okay

21:48 Huh, why isn't sente in ~/.m2/repository?

21:49 TEttinger: under taoensso ?

21:49 lvh: TEttinger: nope

21:49 oh, com.taoensso

21:49 hiredman: do you have a compelling reason to use sente?

21:49 TEttinger: (also it doesn't necessarily correspond to ns, it's the maven artifact naming)

21:50 lvh: hiredman: it seemed like the easiest thing to accomplish what I wanted (push events to the browser)

21:50 also, it worked fine before, and I'm not sure what broke it, so I guess I'll git bisect

21:53 1.6.0-beta1 works like a charm, so I guess it's a sente bug?

21:55 Niac: HOW to write a php interpretor with clojure?

21:56 lvh: Niac: You want to write one from scratch?

21:57 Niac: lvh: yes

21:58 lvh: just some basic caculation

21:58 lvh: Niac: OK, so first figure out how to tokenize and parse (instaparse will probably serve you nicely if you only care about the basics)

22:00 Niac: then, you want to match on expressions and execute the equivalent clojure expression

22:00 Niac: lvh: yes

22:01 lvh: Niac: so, for example, if your parser turns "5 + 1;" into '[5 + 1], you can write e.g. a core.match rule to match on that and do (+ x y) instead.

22:01 (You'd probably want to recursively match so that you can also parse "5 + 1 + 1;")

22:02 hiredman: (of course the semantics won't be phps, just the surface syntax)

22:02 Niac: lvh: what about

22:02 Function scope

22:03 lvh: Niac: I don't know enough about PHP's scoping rules to give you a sensible answer there; sorry.

22:05 Niac: lvh: maybe you can tell me scope in the semantics

22:05 lvh: just about the mind

22:24 TEttinger: Niac: it does not sound like a quick or easy project, unless you choose a very small subset of PHP

22:25 Niac: TEttinger: yes ,just the basic part

22:26 TEttinger: such as?

22:27 do you want to be able to define variables or functions, and would they behave with PHP's bizarre conversion rules or Clojure's more normal ones?

22:27 "" + 5

22:28 in php, I believe that may return "5", in clojure it's an error even after you turn it into (+ "" 5)

22:31 Niac: TEttinger: that's a problem i never thought

22:35 TEttinger: in my way,when do the plus caculation , a string is for zero

22:35 TEttinger: err, nevermind, PHP does not overload +, I was thinking of JS or possibly PHP

22:35 err, nevermind, PHP does not overload +, I was thinking of JS or possibly PHP's equality stuff

22:36 in PHP: NULL < -1, and NULL == 0. Sorting is thus nondeterministic; it depends on the order in which the sort algorithm happens to compare elements.

22:37 http://phpsadness.com/sad/47

22:40 I'm getting most of this from http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

22:47 Incrementing (++) a NULL produces 1. Decrementing (--) a NULL produces NULL. Decrementing a string likewise leaves it unchanged.

23:45 bcham: Likely a stupid question, but would you ever defmacro a macro that returns a function? I just tried one

23:45 and I got an error when I tried to use it saying that I was using a reserved name (and I definitely wasn't)

23:45 any ideas?

23:51 whomp: is there a function which returns true if the element passed in is truthy, i.e. neither nil nor false?

23:52 lvh: whomp: I'm not sure, but #(if % true false) <= looks like it does what you want obv :)

23:52 whomp: lvh, true :)

23:52 ty

23:52 lvh: whomp: heh heh heh

23:52 ,(boolean "abcd")

23:52 clojurebot: true

23:53 lvh: whomp: I guess boolean does what you want?

23:53 whomp: oh cool, never knew that one

23:53 that's perfect

23:55 lvh: I wasn't sure if that's plain-old Java coercion or Clojure truthiness

23:55 ,(boolean nil)

23:55 clojurebot: false

23:55 lvh: ,(boolean [])

23:55 clojurebot: true

23:56 lvh: looks about right though :)

Logging service provided by n01se.net