workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
( or maybe they’re both invalid and :1 just happens to work? )
2017-12-15T15:31:32.000463
Tuyet
clojurians
clojure
correct
2017-12-15T15:32:14.000203
Kareen
clojurians
clojure
they are both invalid literals
2017-12-15T15:32:25.000015
Kareen
clojurians
clojure
:foo/1 happens to work but it's still invalid
2017-12-15T15:32:35.000058
Kareen
clojurians
clojure
<https://clojure.org/reference/reader> - yeah my “read” of this is that :1 is illegal but accidentally works in some cases
2017-12-15T15:32:43.000198
Margaret
clojurians
clojure
well, no, right? because the reader doesn't determine what a valid keyword is
2017-12-15T15:32:48.000632
Rebeca
clojurians
clojure
yep, I said literal
2017-12-15T15:33:06.000306
Kareen
clojurians
clojure
maybe a strict reading of that reference would also imply `:<http://google.com>` is bad, and keywords of that form are used in core libs (and it’s neither here nor there but the reader does accept them)
2017-12-15T15:37:09.000135
Margaret
clojurians
clojure
it was unsettling to see that being used on purprose
2017-12-15T15:38:25.000320
Margaret
clojurians
clojure
If an implementation doesn't stop you, someone somewhere will do it. :slightly_smiling_face:
2017-12-15T15:41:31.000368
Micha
clojurians
clojure
and think it is a great idea
2017-12-15T15:41:55.000040
Rebeca
clojurians
clojure
there is a lot of background on this - the regex for keywords in the reader is actually wrong, which is why it works
2017-12-15T15:44:05.000129
Sonny
clojurians
clojure
we “fixed” it in 1.6 and found out it broke a lot of existing code
2017-12-15T15:44:21.000070
Sonny
clojurians
clojure
so we unfixed it
2017-12-15T15:44:28.000182
Sonny
clojurians
clojure
Taking advantage of such behavior does put you at some kind of risk of a future version of Clojure reserving characters for other purposes, and now either you update your application or don't run it or its data with that version of Clojure. Given sensitivity to backwards compatibility by core team, I doubt they would break such things for fun.
2017-12-15T15:45:12.000055
Micha
clojurians
clojure
I’d say at this point that there is no chance we will take that away
2017-12-15T15:45:36.000171
Sonny
clojurians
clojure
we did break it, and it wasn’t fun
2017-12-15T15:45:45.000043
Sonny
clojurians
clojure
I notice one can now override `*reader-resolver*` in Clojure 1.9. Has anyone tried this? What scenarios is it useful for?
2017-12-15T15:48:25.000390
Edelmira
clojurians
clojure
If I wanted to write a utility that overrode `*reader-resolver*` to do cool stuff, I would have to `alter-var-root` it rather than `bindings` it so that I can load code with that new reader resolver in place, right?
2017-12-15T15:49:38.000364
Edelmira
clojurians
clojure
thx, after all I did this: ``` (def queue (agent [] :error-handler (fn [a ex] (l/error ex "slack agent failed") (restart-agent a @a)))) ```
2017-12-15T15:50:50.000329
Gladys
clojurians
clojure
it’s useful if you want to have control over how namespace-sensitive things resolve (like autoresolved keywords)
2017-12-15T15:50:56.000156
Sonny
clojurians
clojure
Looks like I can affect the behavior of `read-string`: ``` user=&gt; (binding [*reader-resolver* (reify clojure.lang.LispReader$Resolver (resolveAlias [this sym] 'blah))] (read-string "::a/b")) :blah/b ```
2017-12-15T15:51:32.000406
Edelmira
clojurians
clojure
It seems to me that that's the only thing I can do with `binding`
2017-12-15T15:51:54.000333
Edelmira
clojurians
clojure
Just want to make sure that's accurate
2017-12-15T15:51:59.000387
Edelmira
clojurians
clojure
yes
2017-12-15T15:52:04.000296
Sonny
clojurians
clojure
really best for programmatic reader cases where you are creating the environment (not for general code loading in the RT)
2017-12-15T15:52:30.000224
Sonny
clojurians
clojure
gotcha, that's what I wanted to confirm
2017-12-15T15:52:47.000298
Edelmira
clojurians
clojure
thanks
2017-12-15T15:52:48.000322
Edelmira
clojurians
clojure
I was hoping I could write myself a `with-aliases` macro that lets me define arbitrary aliases in local scope or something
2017-12-15T15:53:08.000288
Edelmira
clojurians
clojure
I think reading has already been done at macro time so that wouldn’t work
2017-12-15T15:54:16.000059
Sonny
clojurians
clojure
yep
2017-12-15T15:54:28.000602
Kareen
clojurians
clojure
yep
2017-12-15T15:54:32.000425
Edelmira
clojurians
clojure
unless I use `push-thread-bindings` and `pop-thread-bindings`....
2017-12-15T15:56:36.000212
Edelmira
clojurians
clojure
then I could write a `defalias` macro that pushes a new `*reader-resolver*` for the remainder of that file
2017-12-15T15:57:05.000236
Edelmira
clojurians
clojure
but then I don't know when to pop it
2017-12-15T15:57:15.000218
Edelmira
clojurians
clojure
having a `push-thread-binding` escape its lexical context is not a good idea anyway
2017-12-15T15:59:43.000312
Kareen
clojurians
clojure
``` (ns my.ns) (defalias o other.ns) ::o/a-keyword (end-aliases!) ``` :troll:
2017-12-15T16:00:13.000533
Edelmira
clojurians
clojure
if your `push-thread-binding` gets executed from within a `binding`, that `binding `ill pop the wrong thing
2017-12-15T16:01:07.000056
Kareen
clojurians
clojure
if you are going to be gross, hijack the dispatchMacros table in the reader
2017-12-15T16:01:27.000392
Rebeca
clojurians
clojure
haha
2017-12-15T16:02:06.000163
Kareen
clojurians
clojure
brb forking Clojure
2017-12-15T16:02:13.000402
Edelmira
clojurians
clojure
Am I missing something, or does Clojure not have a way to refer to a piece of code from a docstring? I’m hoping to hyperlink between namespaces when an implicit dependency exists. I’ve considered using #_ macros but that invokes a (requires) clause I’d rather avoid.
2017-12-15T17:02:52.000047
Mari
clojurians
clojure
IDE stack is Cursive with a close fallback of Emacs/etc
2017-12-15T17:03:21.000102
Mari
clojurians
clojure
you could use metadata
2017-12-15T17:04:42.000122
Jonas
clojurians
clojure
<@Mari> there is no standardized docstring markup for referring to symbols.
2017-12-15T17:07:00.000165
Charity
clojurians
clojure
instead of encoding it in the doc string and then having a way to parse it out
2017-12-15T17:07:12.000291
Jonas
clojurians
clojure
you could just be explicit with meta data `(defn ^{:refers-to 'other.name-space} foo [] 42)`
2017-12-15T17:07:14.000158
Jonas
clojurians
clojure
<@Charity> okay! glad to know it for sure
2017-12-15T17:07:30.000175
Mari
clojurians
clojure
Some authors use Markdown style `backtick` blocks. I personally like to use `#'foo` or `#'other-ns/foo` var notation in backtick blocks in docstrings.
2017-12-15T17:07:55.000332
Charity
clojurians
clojure
<@Jonas> okay that is interesting. I can do it without require, then? I’ll see whether cursive/etc pick up on it
2017-12-15T17:07:59.000121
Mari
clojurians
clojure
Some of the tools support wiki-style `[[my.other/thing]]` references.
2017-12-15T17:08:14.000101
Charity
clojurians
clojure
`#'` is also a good point, thanks
2017-12-15T17:08:14.000347
Mari
clojurians
clojure
lessee…
2017-12-15T17:08:23.000027
Mari
clojurians
clojure
the meta-data keyword is completely made up by me, so if you wanted ide support, you’d have to add it
2017-12-15T17:08:54.000252
Jonas
clojurians
clojure
ah
2017-12-15T17:09:43.000074
Mari
clojurians
clojure
just trying to say that this isn’t a standardized practice. just a suggestion for how you could start one if you wanted
2017-12-15T17:09:46.000045
Jonas
clojurians
clojure
Cursive is trying hard to resolve it, though. just failing…
2017-12-15T17:09:54.000494
Mari
clojurians
clojure
hm. of course the real problem is that this is across Clojure/ClojureScript code where I can’t exactly write cljc.
2017-12-15T17:10:32.000029
Mari
clojurians
clojure
maybe I will find a way to cljc it, but for now, I have to keep the people reading the code aware.
2017-12-15T17:11:10.000281
Mari
clojurians
clojure
Where would I RFC on such a thing?
2017-12-15T17:13:12.000179
Mari
clojurians
clojure
I’ll take it to <#C0744GXCJ|cursive> in case it appeals…
2017-12-15T17:14:09.000237
Mari
clojurians
clojure
Hey all, I'm wondering in clojure since there aren't really object methods how do I know what functions I can use on something?
2017-12-15T17:20:10.000034
Floretta
clojurians
clojure
For example, how do I know all the methods I can use on a channel made from core.async's (chan)?
2017-12-15T17:20:40.000071
Floretta
clojurians
clojure
Clojure seems to follow this philosophy: <https://stackoverflow.com/questions/6016271/why-is-it-better-to-have-100-functions-operate-on-one-data-structure-than-10-fun>
2017-12-15T17:20:59.000313
Berry
clojurians
clojure
thanks, but that doesn't really answer my question. For example, I'd expect from that philosophy to be able to do "nth", "count", "map", etc
2017-12-15T17:22:19.000459
Floretta
clojurians
clojure
But none of these actually work so I'm wondering what are the methods that work for chan
2017-12-15T17:22:35.000245
Floretta
clojurians
clojure
I'm not sure if this helps either: you can lookup all the protocols that chan implements, then look at functions that depend on those protocols
2017-12-15T17:23:31.000042
Berry
clojurians
clojure
also, I'm pretty sure you can do something map/transducer like on chans
2017-12-15T17:23:53.000453
Berry
clojurians
clojure
for channels specifically, most of the functions that work with channels can be found at <https://clojure.github.io/core.async/>
2017-12-15T17:26:54.000227
Jonas
clojurians
clojure
hey guys, is there any file reader transducer in any core library? Something that can be used to stream-read from a file, as part of a transducing process? Or should I work up a transducer around lazy file reading myself (which is what I'm about to be doing now)
2017-12-15T17:26:55.000074
Kalyn
clojurians
clojure
<@Kalyn> not sure is worth a lib, is this something useful? <https://gist.github.com/reborg/2d9b31f2209f9b3afd1dc401b3dffc2c#file-split-by-clj-L55>
2017-12-15T17:28:45.000295
Eliana
clojurians
clojure
<@Berry> I'm not really sure what you mean. How would Iook up all the protocols for channel?
2017-12-15T17:28:48.000021
Floretta
clojurians
clojure
<@Jonas> Those are just functions within the core.async namespace, NOT functions that I can use on a ManyToManyChannel
2017-12-15T17:29:38.000017
Floretta
clojurians
clojure
<@Eliana> yes, but doesn't that snippet show a transduction that is specific to the file reader? doesn't it go against the motivation for transducers? as in being generically applicable regardless of the actual input source
2017-12-15T17:30:44.000275
Kalyn
clojurians
clojure
<@Floretta>, there’s not really a great way to obtain a list of every function that takes a ManyToMany channel as it’s first argument
2017-12-15T17:30:53.000288
Jonas
clojurians
clojure
<@Eliana> mmm on second thought maybe you are right and this is just trivial
2017-12-15T17:32:28.000027
Kalyn
clojurians
clojure
whynot
2017-12-15T17:34:24.000003
Floretta
clojurians
clojure
a couple things, 1) ManyToManyChannel is a concrete type, <https://github.com/clojure/core.async/blob/0498ba69fda5d930e3e7568cc90ca933c19c42ca/src/main/clojure/cljs/core/async/impl/channels.cljs#L30>
2017-12-15T17:35:07.000255
Jonas
clojurians
clojure
and you often want to program against abstract types instead of concrete types
2017-12-15T17:35:19.000206
Jonas
clojurians
clojure
2) since clojure’s protocol system is open
2017-12-15T17:35:41.000181
Jonas
clojurians
clojure
at runtime, more protocols can be extended to work with the concrete type of ManyToManyChannel
2017-12-15T17:36:12.000197
Jonas
clojurians
clojure
Do you have a specific idea about how a possible API would look like in this case? Trying to understand if there is room for improvement
2017-12-15T17:36:31.000276
Eliana
clojurians
clojure
3) in addition, anyone could write a function that takes a ManyToManyChannel as it’s first argument
2017-12-15T17:36:52.000122
Jonas
clojurians
clojure
or if the ManyToManyChannel was added to more protocols, then at any point, any protocol can start working with ManyToManyChannel
2017-12-15T17:38:03.000129
Jonas
clojurians
clojure
for most clojure functions, the types that functions expect aren’t annotated anywhere
2017-12-15T17:38:53.000033
Jonas
clojurians
clojure
so even if you went through every function in every namespace, there’s not typically a good way to ask if a particular function accepts a particular type
2017-12-15T17:39:50.000074
Jonas
clojurians
clojure
basically, clojure tends to adopt an approach that is dynamic and open which makes it more difficult to answer questions like “which functions work with the type?”
2017-12-15T17:41:39.000291
Jonas
clojurians
clojure
but makes a lot of other designs easier
2017-12-15T17:42:01.000106
Jonas
clojurians
clojure
I was under the impression that things like `(take 1 (drop 40000000 (iterate inc 1)))` would take constant memory but it doesn’t appear so. Could somebody explain what exactly happens here?
2017-12-15T17:57:02.000315
Lester
clojurians
clojure
I get “Out of memory” on a constrained system while running this
2017-12-15T17:57:57.000178
Lester
clojurians
clojure
<@Lester>, how constrained?
2017-12-15T18:02:55.000246
Jonas
clojurians
clojure
it’s <http://repl.it|repl.it> so I have no idea, but the memory assigned there must be somewhat small
2017-12-15T18:03:22.000193
Lester
clojurians
clojure
but that shoudn’t matter if my assumption that this will take constant memory is correct
2017-12-15T18:03:48.000213
Lester
clojurians
clojure
I think it does take constant memory
2017-12-15T18:04:39.000277
Jonas
clojurians
clojure
my thinking was that `iterate` will return a lazy seq, `drop` will basically throw away elements as it goes and `first` will just cut the remaining lazy-seq and everything will be garbage collected
2017-12-15T18:05:09.000244
Lester
clojurians
clojure
and those 40M elements won’t be allocated anywhere
2017-12-15T18:05:27.000379
Lester
clojurians
clojure
that was my impression as well
2017-12-15T18:07:09.000196
Jonas
clojurians
clojure
the one common issue is “hanging onto the head”
2017-12-15T18:07:54.000210
Jonas
clojurians
clojure
I fail to see that in my example
2017-12-15T18:08:14.000193
Lester
clojurians
clojure
<https://repl.it/repls/CultivatedAridStegosaurus>
2017-12-15T18:08:15.000240
Lester