workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
looks like the site is down today? (?!)
2017-12-16T03:07:16.000020
Kalyn
clojurians
clojure
<@Berry> why don't you use comma for that ?
2017-12-16T03:10:42.000033
Jami
clojurians
clojure
it seems that '|' is a vaid symol, like + or -
2017-12-16T03:11:28.000040
Jami
clojurians
clojure
Your implementation looks flawless in also closing the file "the transducer way"
2017-12-16T03:21:05.000018
Kalyn
clojurians
clojure
Is there any reason :clj: uses `2 + Runtime.getRuntime().availableProcessors()` for `Agent/pooledExecutor` (<https://github.com/clojure/clojure/blob/clojure-1.9.0/src/jvm/clojure/lang/Agent.java#L50>) and `pmap` (<https://github.com/clojure/clojure/blob/clojure-1.9.0/src/clj/clojure/core.clj#L6941>)? Why the `2 +`?
2017-12-16T06:47:55.000018
Andra
clojurians
clojure
<@Daniell> that code seems to defy the normal order of compilation, in that it refers to `fib` in its own `def`inition, and it's not obvious how the compiler handles that!
2017-12-16T07:37:38.000038
Beulah
clojurians
clojure
<@Beulah> symbols referring to vars are implicitly dereferenced by the compiler
2017-12-16T08:10:35.000002
Rosia
clojurians
clojure
<@Beulah>which means ?
2017-12-16T08:30:32.000126
Beulah
clojurians
clojure
<@Rosia> which means ?
2017-12-16T08:30:52.000056
Beulah
clojurians
clojure
it means you are allowed to self-refer the var you're defining, as long as the access is deferred (what lazy-seq does)
2017-12-16T08:32:29.000069
Rosia
clojurians
clojure
when the root value is evaluated, the var has already been created
2017-12-16T08:33:17.000025
Rosia
clojurians
clojure
<@Rosia> what do you mean by 'root value' ?
2017-12-16T08:38:14.000047
Beulah
clojurians
clojure
the value held by your var
2017-12-16T08:38:51.000092
Rosia
clojurians
clojure
which in this case is `(concat [1 1] (lazy-seq (map + (rest fib) fib)))`
2017-12-16T08:39:21.000082
Beulah
clojurians
clojure
yes, but during the evaluation of that, the root value is undefined, that's why you need to defer
2017-12-16T08:40:50.000055
Rosia
clojurians
clojure
try e.g `(def a a)`
2017-12-16T08:41:13.000102
Rosia
clojurians
clojure
ok, just to be clear, a var has a value, are you saying it also has another value called its 'root value' ? i.e. does a var have 2 values: its value and its root-value and if so what's the difference ?
2017-12-16T08:42:27.000079
Beulah
clojurians
clojure
no, the difference is meaningful only for dynamic vars
2017-12-16T08:43:12.000006
Rosia
clojurians
clojure
but this isn't a dynamic var
2017-12-16T08:43:31.000076
Beulah
clojurians
clojure
static vars have always one value and this value can be a sentinel if this var has not yet been bound
2017-12-16T08:44:40.000004
Rosia
clojurians
clojure
ok so we could just say 'value' in this case
2017-12-16T08:44:58.000061
Beulah
clojurians
clojure
I guess so
2017-12-16T08:46:34.000001
Rosia
clojurians
clojure
alright so the point is that `lazy-seq` defers evaluation (until realized by `take` or something)
2017-12-16T08:47:11.000096
Beulah
clojurians
clojure
so what appears to be an intractable self-reference isn't really because at the time the `lazy-seq` is realized the var `fib` has a value, which is `(concat...)`
2017-12-16T08:49:02.000039
Beulah
clojurians
clojure
and when the `def` is evaluated, the `lazy-seq` isn't actually realized, it's only created
2017-12-16T08:49:54.000033
Beulah
clojurians
clojure
right
2017-12-16T08:50:05.000094
Rosia
clojurians
clojure
it's confusing because it doesn't read like that
2017-12-16T08:51:06.000070
Beulah
clojurians
clojure
it reads as an atomic definition
2017-12-16T08:51:16.000010
Beulah
clojurians
clojure
there's no indication as to the 2-pass evaluation
2017-12-16T08:51:36.000056
Beulah
clojurians
clojure
I think it's hard to reason about time in that code
2017-12-16T08:52:42.000030
Beulah
clojurians
clojure
it's not that much common afaik
2017-12-16T08:53:22.000004
Rosia
clojurians
clojure
no I've only ever seen that example - it's lovely though!
2017-12-16T08:53:43.000038
Beulah
clojurians
clojure
The only way --in really most programming languages-- to write code that isnt' evaluated is to put it into a function. Naturally `(def x (foo))` is different to `(def x (fn[] (foo))`
2017-12-16T08:54:12.000044
Randee
clojurians
clojure
So that's exactly what the `lazy-seq` does (it's a macro that wrapps the code in a function)
2017-12-16T08:54:41.000091
Randee
clojurians
clojure
<@Randee> or `delay`
2017-12-16T08:54:58.000021
Beulah
clojurians
clojure
It's just a function definition. Under the hood lazy seqs hide that.
2017-12-16T08:55:03.000126
Randee
clojurians
clojure
<@Beulah> Again, delay is JUST a function under the hood
2017-12-16T08:55:15.000090
Randee
clojurians
clojure
Try writing a lazy seq in Javascript. Totally possible since you have functions. You're API would just be a little different accessing that lazy seq.
2017-12-16T08:56:02.000051
Randee
clojurians
clojure
that doesn't sound enjoyable
2017-12-16T08:56:27.000033
Beulah
clojurians
clojure
Your mind probably woulnt' have a problem with that code: `(def foo [0 1 (fn [] [2 3 (foo)])])`, right?
2017-12-16T08:58:56.000038
Randee
clojurians
clojure
it's pretty straightforward - you just need an object that holds a function and an optional value
2017-12-16T08:59:01.000008
Margaret
clojurians
clojure
Hi. What lib you would recommend to use with GraphQL? I found several and don't know which I should to choose
2017-12-16T08:59:12.000128
Marcos
clojurians
clojure
I understand right what I need to use GraphQL both in cljs and clj sides of my site?
2017-12-16T08:59:18.000003
Marcos
clojurians
clojure
<@Marcos> lacinia
2017-12-16T09:59:19.000029
Marty
clojurians
clojure
is maintained by walmart
2017-12-16T10:00:05.000189
Marty
clojurians
clojure
<@Marty>, thanks
2017-12-16T10:17:50.000082
Marcos
clojurians
clojure
there is also <#C4DLZKR9T|graphql> which could be interesting if you start using it
2017-12-16T10:18:42.000104
Daine
clojurians
clojure
<@Daine>, joined, thanks
2017-12-16T10:19:45.000043
Marcos
clojurians
clojure
Hi! Tomorrow, on Sunday at 12am UTC, I’m going to stream live Clojure coding solving some issues for my open source Etaoin library. Recorded version will be stored on Youtube automatically. Watch it here: <https://www.youtube.com/watch?v=cLL_5rETLWY>
2017-12-16T11:45:25.000010
Verna
clojurians
clojure
Is there a de facto parser combinator library for clojure?
2017-12-16T14:17:36.000049
Johana
clojurians
clojure
So there is/was fnparse, but the original is super stale the maintainer vanished and there’s no clear winner of the forks.
2017-12-16T14:19:49.000061
Charity
clojurians
clojure
It lets you write pretty trivial recursive decent parsers easily.
2017-12-16T14:20:06.000113
Charity
clojurians
clojure
Instaparse exists and I’d suggest you start there. Using the ordered choice operator you can optimize your grammars moderately well.
2017-12-16T14:20:33.000020
Charity
clojurians
clojure
Antlr4 or one of its wrappers if you really need performance.
2017-12-16T14:20:43.000071
Charity
clojurians
clojure
<@Charity> I wanted to check if I could get something faster than InstaParse and nicer than hand written (for some value of nice): <https://github.com/borkdude/aoc2017/blob/master/src/day16.clj#L118>
2017-12-16T14:21:24.000074
Johana
clojurians
clojure
<@Johana> try replacing unordered choice `|` with ordered choice `/` in your grammar and see how that does.
2017-12-16T14:22:26.000010
Charity
clojurians
clojure
<@Johana> Instaparse tries really hard to support ambiguously parsing syntaxes with fully unordered choice. Looks like your grammar is actually LL(1) and not ambiguous so you can use ordered choice to make it clear that your grammar is less general.
2017-12-16T14:23:18.000089
Charity
clojurians
clojure
It actually becomes a bit slower that way
2017-12-16T14:24:49.000052
Johana
clojurians
clojure
Not significantly, probably doesn’t help nor hurt
2017-12-16T14:25:10.000024
Johana
clojurians
clojure
One issue is that Instaparse has to generate nested items first which get resolved in the transform phase
2017-12-16T14:25:40.000073
Johana
clojurians
clojure
:shrug:
2017-12-16T14:25:43.000022
Charity
clojurians
clojure
And with a parser combinator lib I might get to do that during processing
2017-12-16T14:25:58.000069
Johana
clojurians
clojure
You can. That’s how my first compiler written in fnparse worked. You can also use Antlr4 visitors/listeners to perform evaluation during parsing.
2017-12-16T14:26:33.000101
Charity
clojurians
clojure
Instaparse doesn’t and won’t support doing this for good reason. I talked to <@Edelmira> about this at some point.
2017-12-16T14:27:11.000078
Charity
clojurians
clojure
Besides you’re down in ms here, the measurement error is probably significant.
2017-12-16T14:27:35.000032
Charity
clojurians
clojure
With | 582 ms, with / 591 ms, measured by criterium
2017-12-16T14:34:01.000014
Johana
clojurians
clojure
As Alex explained, IP does a lot of bookkeeping, don’t know the exact details, but this can make it slower than simple hand rolled parsing.
2017-12-16T14:34:38.000076
Johana
clojurians
clojure
Parser combinators don’t seem really popular in Clojure somehow.
2017-12-16T14:35:02.000003
Johana
clojurians
clojure
I've been playing around a little with <https://github.com/blancas/kern>. I'm pretty new to parser/combinators as a tool though, so I can't comment on what's good or not so good.
2017-12-16T14:41:10.000104
Bibi
clojurians
clojure
Thanks!
2017-12-16T14:41:43.000044
Johana
clojurians
clojure
Funny, I'm using AoC to learn this, too :slightly_smiling_face:
2017-12-16T15:06:42.000051
Bibi
clojurians
clojure
yeah - I'd never had that issue before, but it's up now
2017-12-16T16:23:24.000067
Margaret
clojurians
clojure
Kern implementation: <https://github.com/borkdude/aoc2017/blob/master/src/day16.clj#L115>
2017-12-16T16:54:22.000049
Johana
clojurians
clojure
advanced clojure book written from the post 1.7 perspective? recommendations anyone? :slightly_smiling_face:
2017-12-16T17:31:57.000059
Kalyn
clojurians
clojure
I see this one isn't out yet by the way, no idea what is its table of contents like <https://www.amazon.com/Programming-Clojure-Alex-Miller/dp/1680502468/ref=sr_1_7?s=books&amp;ie=UTF8&amp;qid=1513463397&amp;sr=1-7&amp;keywords=clojure>
2017-12-16T17:34:15.000035
Kalyn
clojurians
clojure
Is there anyone using Lacinia ? Great job! But, I am so sceptic. I have some questions.
2017-12-16T17:36:37.000036
Olen
clojurians
clojure
<@Kalyn> Programming Clojure 3rd Ed would be a good purchase -- assuming you like e-books and don't mind getting updates while it's in pre-release form? Otherwise I'd recommend Clojure Applied if you want something beyond intro/mid-level.
2017-12-16T17:49:25.000018
Daniell
clojurians
clojure
<@Olen> at <#C4DLZKR9T|graphql> there are quit some questions, I also want to try it at somewhere soon
2017-12-16T17:50:01.000056
Daine
clojurians
clojure
I have a probably dumb compojure-api question. (happy to take it somewhere else there's a better channel for this). I think I'm missing something very obvious, but if I return a core.async channel from a route in `compojure-api`, I get an error about channels not implementing `render`. I'm running 2.0-alpha16 and doing something super similar to the example in the readme. I'm sure this will be a facepalm moment, but what's the obvious thing I'm missing?
2017-12-16T17:57:46.000037
Michelina
clojurians
clojure
<@Daine> thank you. :innocent:
2017-12-16T18:00:18.000054
Olen
clojurians
clojure
you finally pushed me to start the advent of code. my solution to day 16: <https://github.com/wiseman/advent-of-code/blob/master/2017/day16/src/day16.clj#L39-L59>
2017-12-16T18:14:18.000068
Alline
clojurians
clojure
Ah, nevermind. I just needed to show httpkit how to interface with ring-async
2017-12-16T18:22:38.000029
Michelina
clojurians
clojure
Just saw this and thought it was really interesting...but I don't know what IK is. Seems like there was some part of this discussion I missed?
2017-12-16T18:24:20.000058
Jerold
clojurians
clojure
<@Sandy> Was just revisiting this article: <http://blog.cognitect.com/blog/2016/9/15/works-on-my-machine-understanding-var-bindings-and-roots> and noticed that there was never a follow-up on `Var$TBox` :stuck_out_tongue: &gt; The rationale behind TBox-es will have to wait until a later time What's the reason `Frame` bindings are maps of `Var -&gt; TBox` instead of just `Var -&gt; &lt;value&gt;`? Since `dvals` is thread-local, all threads a `Frame`'s `TBox`s are the same, which my experiments seem to confirm.
2017-12-16T18:55:42.000028
Andra
clojurians
clojure
<@Andra> It's mostly to stop you from shooting yourself in the foot. There's some strange cases where you could cause cross-thread mutation with `set!` and bindings. I don' have a REPL infront of me at the moment, but I think this would cause the error: ``` (def ^:dynamic myval nil) (binding [myval 32] (set! myval 42) (future (set! myval 45))) ```
2017-12-16T20:45:31.000067
Sandy
clojurians
clojure
So that's the gist of it, we bound a dynamic var, set! a value locally, then tried to set it again in another thread. I think that will cause an error and that error occurs when you set an already set val from a different thread than the first set!. The thread that set the value is tracked in TBox.
2017-12-16T20:47:55.000059
Sandy
clojurians
clojure
Using TBox also improves performance a bit, since set! is then allocation free. Without TBox you'd have to do an assoc into the contents of the current Frame, and that would require an allocation.
2017-12-16T20:48:51.000017
Sandy
clojurians
clojure
I see, so it's to handle binding conveyance? B/c AFAICT that's the only way frames are shared b/t threads. Relevant code: <https://github.com/clojure/clojure/blob/clojure-1.9.0/src/jvm/clojure/lang/Var.java#L219>
2017-12-16T20:55:51.000053
Andra
clojurians
clojure
But I'm actually not sure why the two `set!`s is a problem? Each thread gets its own frames, so they won't interfere w/ each other.
2017-12-16T21:06:33.000069
Andra
clojurians
clojure
Does anyone else here see a need for something like: <https://github.com/aaronc/c-in-clj> but targetting both webassembly (to be called from cljs) and cuda (to be calledc from clojure/jcuda)? I want to write high performance numerical code in something that is clojure-like, and be able to invoke it directly from clojure
2017-12-17T00:35:54.000014
Berry
clojurians
clojure
<@Berry> Did you look at Ferret? <https://github.com/nakkaya/ferret>
2017-12-17T00:51:33.000020
Silas
clojurians
clojure
<https://ferret-lang.org/> looks pretty amazing
2017-12-17T01:41:44.000017
Berry
clojurians
clojure
Is there a way, either using transient! vector or a native java array, to get CONSTANT TIME, not log_32 N time for following op: set n-th element of array/vector/object to :foo
2017-12-17T02:51:14.000105
Berry
clojurians
clojure
<@Michelina> You might not be running the server on async-mode? Adding `{:async? true}` to jetty opts enables the async chain.
2017-12-17T03:56:59.000033
Alla
clojurians
clojure
there is also <#C0A5GSC6T|ring> for ring async and <#C06GSN6R2|ring-swagger> with c-api things too
2017-12-17T03:57:28.000043
Alla
clojurians
clojure
<@Daniell> oh is it already available as an e-book?
2017-12-17T05:46:40.000070
Kalyn
clojurians
clojure
I wish there was a TOC of it to look at, but on Amazon there’s none yet
2017-12-17T05:48:38.000041
Kalyn
clojurians
clojure
going to start in 10-15 minutes <https://www.youtube.com/watch?v=cLL_5rETLWY>
2017-12-17T06:48:35.000014
Verna
clojurians
clojure
<@Verna>, we are waiting!
2017-12-17T06:51:16.000011
Olen
clojurians
clojure
what is this? are you live casting using a library to control a web browser via clojure ?
2017-12-17T06:52:52.000098
Berry