workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
clojurians | clojure | why do i get an invalid number exception for `0x1.0p-53`? | 2017-11-17T06:46:38.000023 | Donella |
clojurians | clojure | because that's not a valid clojure number literal | 2017-11-17T06:48:03.000160 | Kareen |
clojurians | clojure | but it works in java | 2017-11-17T06:48:12.000029 | Donella |
clojurians | clojure | and it doesn't in clojure | 2017-11-17T06:48:18.000076 | Kareen |
clojurians | clojure | they have different lexers | 2017-11-17T06:48:21.000143 | Kareen |
clojurians | clojure | clojure docs say "As of version 1.3, Clojure provides full support for JVM primitive values, making it possible to write high performance, idiomatic Clojure code for numeric applications." | 2017-11-17T06:48:44.000085 | Donella |
clojurians | clojure | and that's true | 2017-11-17T06:49:11.000024 | Kareen |
clojurians | clojure | what it doesn't say is that clojure will accept all java literals | 2017-11-17T06:49:19.000318 | Kareen |
clojurians | clojure | because it doesn't | 2017-11-17T06:49:27.000067 | Kareen |
clojurians | clojure | so if it did accept more literals for primitives, you wouldn't say that support for primitives has been improved? | 2017-11-17T06:50:42.000169 | Donella |
clojurians | clojure | That's fine. It's a local though, and not a var. Vars are the things that `def` and `defn` create at the top level. You shouldn't define those more that once (except at the repl, when developing). | 2017-11-17T07:52:02.000157 | Giovanna |
clojurians | clojure | Feel free to file a ticket - Java has added stuff over the years and I don’t see any reason we shouldn’t track their literal | 2017-11-17T09:23:45.000454 | Sonny |
clojurians | clojure | Hi everyone, I have an interview coming up for which the recruiter told me to prepare for datastructures questions. I know I should review them, but I'm loathed to learn about mutable versions as I never use them anymore :confused: Id much rather learn about immutable implementations so that at least its relevant to my interests. How come there are so many tutorials for mutable but not immutable datastructures | 2017-11-17T10:04:53.000128 | Tobie |
clojurians | clojure | Moreover, its actually not natural to create a mutable datastructure in clojure i find | 2017-11-17T10:05:26.000513 | Tobie |
clojurians | clojure | All I remember is that Clojure uses something called HAMT | 2017-11-17T10:05:58.000239 | Jonnie |
clojurians | clojure | (IIRC - a bit fuzzy on this, although I did some reading a long time ago) | 2017-11-17T10:06:25.000288 | Jonnie |
clojurians | clojure | <https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java#L18-L26> | 2017-11-17T10:07:10.000083 | Jonnie |
clojurians | clojure | The comment is actually pretty clear | 2017-11-17T10:07:28.000220 | Jonnie |
clojurians | clojure | Thanks <@Jonnie> looks good | 2017-11-17T10:10:26.000286 | Tobie |
clojurians | clojure | I'm thinking more along the lines of if asked to implement a binary tree, how would i implement a persistant version | 2017-11-17T10:10:41.000809 | Tobie |
clojurians | clojure | oh right. I think I did something like that on.. codewars maybe? | 2017-11-17T10:11:08.000242 | Jonnie |
clojurians | clojure | They have two “katas” that make you implement these IIRC | 2017-11-17T10:11:22.000028 | Jonnie |
clojurians | clojure | But I agree overall, there is a gap in knowledge about these immutable data structures | 2017-11-17T10:11:49.000038 | Jonnie |
clojurians | clojure | <https://www.codewars.com/kata/functional-binary-trees> I think that was the exercise | 2017-11-17T10:12:23.000189 | Jonnie |
clojurians | clojure | This looks great :slightly_smiling_face: | 2017-11-17T10:14:22.000002 | Tobie |
clojurians | clojure | i wish there were more like this | 2017-11-17T10:14:27.000591 | Tobie |
clojurians | clojure | but yes this is the sort of thing im looking for | 2017-11-17T10:14:37.000189 | Tobie |
clojurians | clojure | Definitely :slightly_smiling_face: If you come across some more I would be interested to hear about it :stuck_out_tongue: | 2017-11-17T10:19:19.000817 | Jonnie |
clojurians | clojure | Hello! Are there libraries that manipulate plain datastructures in the fashion of Datomic pull syntax? | 2017-11-17T12:14:59.000234 | Ernesto |
clojurians | clojure | I saw this, but seems not quite alive | 2017-11-17T12:15:21.000142 | Ernesto |
clojurians | clojure | <https://github.com/LockedOn/graph-router> | 2017-11-17T12:15:22.000459 | Ernesto |
clojurians | clojure | Thanks! | 2017-11-17T12:16:15.000160 | Ernesto |
clojurians | clojure | 3 days ago, <@Lois> and <@Eliana> had an exchange about transduce-ing a transformation. I found the exchange interesting and helpful for learning transducers, and I thought it might be useful to stick it somewhere more enduring than this Slack channel. So, with their permission, I wrote it up and posted it to StackOverflow [1].
One of the side benefits is to have more Clojure content on StackOverflow, which will help us look better next time they analyze languages. I welcome others to similarly capture interesting or useful content from here to StackOverflow. (Or even go the other way and post a question there first, linking to it here.) Totally voluntary, of course, but I think it might benefit our broader community. Cheers!
[1] <https://stackoverflow.com/q/47358416/202292> | 2017-11-17T15:13:28.000638 | Adelaida |
clojurians | clojure | Starting to like transducers are lot now: <https://stackoverflow.com/a/47354316/6264> | 2017-11-17T16:08:05.000204 | Johana |
clojurians | clojure | I’m wondering on which kind of things you can apply them also, instead of collections, text files, SQL results? | 2017-11-17T16:08:29.000436 | Johana |
clojurians | clojure | When files are loaded, when does macros expand? Would my macros expand before earlier def ? And in my case, before earlier spec s/def ? | 2017-11-17T16:11:38.000275 | Silas |
clojurians | clojure | Or do they expand in parralel? | 2017-11-17T16:13:58.000222 | Silas |
clojurians | clojure | the compilation unit for clojure is a form | 2017-11-17T16:19:46.000410 | Rebeca |
clojurians | clojure | so a single form is compiled to bytecode at a time, and macroexpansion needs to happen before bytecode can be generated, so macroexpansion is a form (a top level form, at a time) | 2017-11-17T16:20:23.000281 | Rebeca |
clojurians | clojure | Oh, ok, and in order from top to bottom in the file, and then for each top level form, it goes inner form to outer form? | 2017-11-17T16:21:36.000347 | Silas |
clojurians | clojure | no | 2017-11-17T16:21:52.000119 | Rebeca |
clojurians | clojure | macro expansion happens outer to inner (I could mixing this up, but I don't believe I am) | 2017-11-17T16:23:06.000234 | Rebeca |
clojurians | clojure | Oh right, I think I remember that | 2017-11-17T16:23:47.000352 | Silas |
clojurians | clojure | this is way something like (when-let (some-macro-that-expands-to-a-binding-vector) ...) doesn't work | 2017-11-17T16:23:58.000106 | Rebeca |
clojurians | clojure | Ya, I guess it does, when you have a macro inside another, and call macroexpand-1, you only see the outer one expanded. | 2017-11-17T16:24:49.000447 | Silas |
clojurians | clojure | I'll get us back on topic, why is it discouraged to wrap macros in functions to allow to compose them? | 2017-11-17T16:33:19.000015 | Silas |
clojurians | clojure | Like how apply-macro says its madness: <https://clojure.github.io/clojure-contrib/apply-macro-api.html> | 2017-11-17T16:33:42.000507 | Silas |
clojurians | clojure | The guidance I've always felt I got from the Clojure/core folks was: always write functions first, then use macros only to provide syntactic sugar (or to achieve something that is impossible in a function -- but even then, use the macro to translate it to a function call). | 2017-11-17T16:34:54.000104 | Daniell |
clojurians | clojure | A use case I find commonly is I want to extend an existing macro. So I want to maybe transform the input to the macro, before sending it to the macro. I can't, because I can't evaluate the args to the macro, so I'm always stuck having to write a macro that wraps the other macro. | 2017-11-17T16:36:48.000341 | Silas |
clojurians | clojure | A lot of macros can also be replaced by passing functions instead of a body I think | 2017-11-17T16:38:38.000349 | Johana |
clojurians | clojure | Not that it’s convenient, but you can. I mean the `with-` kind of macros which is 90% of the macros I write. | 2017-11-17T16:38:46.000138 | Johana |
clojurians | clojure | Hum, that's true, or can be written like that if you take thunks as the predicates | 2017-11-17T16:40:19.000153 | Silas |
clojurians | clojure | > I'm always stuck having to write a macro that wraps the other macro
Right, because "macros don't compose". If a macro really is just a thin syntactic wrapper to a function, then you can compose functions and then write just a thin veneer macro around it -- wrapping the functionality, not the other macro. | 2017-11-17T16:40:35.000512 | Daniell |
clojurians | clojure | Ya, and I've trying that more so now, to have my macro implementation be full of normal functions, and the macro just does the unorthodox composition of them. But I think when you want to extend a macro in some other lib, like a core macro, its more confusing to me, though maybe I need to just start digging into those * functions inside, and see that I can use those directly or within my macro, avoiding the need to wrap the macro. | 2017-11-17T16:45:19.000392 | Silas |
clojurians | clojure | I guess I'm trying to understand why macros don't compose. Could they compose? Is there other constructs out there that are different to macros, yet offer similar benefits but also compose | 2017-11-17T16:47:05.000435 | Silas |
clojurians | clojure | what core macro have you wanted to extend? | 2017-11-17T16:47:39.000105 | Willow |
clojurians | clojure | Well, right now I extended s/keys from clojure.spec | 2017-11-17T16:48:02.000172 | Silas |
clojurians | clojure | That's what got me thinking | 2017-11-17T16:48:17.000177 | Silas |
clojurians | clojure | All I do is (s/and the spec from s/keys and another predicate that needs the same input to s/keys. | 2017-11-17T16:49:01.000347 | Silas |
clojurians | clojure | Macros are all about the evaluation model. If you understand that, you will know how they can compose. I've written about this here, in case it's helpful: <http://blog.altometrics.com/2016/04/a-few-tips-for-writing-macros-in-clojure/> | 2017-11-17T16:49:36.000282 | Adelaida |
clojurians | clojure | And I was like, why can't this be a function, and its because I can't pass the arguments to a function to the s/keys macros | 2017-11-17T16:49:37.000376 | Silas |
clojurians | clojure | Cool, I'll give it a read. | 2017-11-17T16:51:15.000136 | Silas |
clojurians | clojure | I guess I've been reading a bit about rebol: <http://blog.hostilefork.com/rebol-vs-lisp-macros/> | 2017-11-17T17:02:18.000477 | Silas |
clojurians | clojure | And I've noticed that one of the limitations of macros from composing in Clojure is that they evaluate at compile time. They act like a pre-processor, and don't have runtime context. | 2017-11-17T17:02:56.000311 | Silas |
clojurians | clojure | And so, you can pass quoted code to functions, and then the function can choose to eval it, but eval also runs without context, so the code you pass quoted does not carry an environment, all bindings are lost. | 2017-11-17T17:03:36.000297 | Silas |
clojurians | clojure | But why doesn't Lisps also allow a way to pass code with its environment, like Rebol does? It seems like it could be an interesting thing. | 2017-11-17T17:04:31.000198 | Silas |
clojurians | clojure | This is a specific case where the implementation of the macro is just wrapped around a function. Alex has acknowledged that and has said a more programmatic API is coming. This is just alpha at the moment. | 2017-11-17T17:04:35.000236 | Daniell |
clojurians | clojure | Now, functions can be passed with an environment, but they can't be transformed before being evaluated, so again its limiting in some ways. | 2017-11-17T17:05:00.000399 | Silas |
clojurians | clojure | What they usually mean with “macros don’t compose”: <https://softwareengineering.stackexchange.com/questions/222559/is-it-fair-to-say-that-macros-dont-compose> | 2017-11-17T17:05:17.000241 | Johana |
clojurians | clojure | Oh, that's pretty good to know. | 2017-11-17T17:05:32.000458 | Silas |
clojurians | clojure | I.e. you cannot pass them around as values like you can with functions. | 2017-11-17T17:05:33.000275 | Johana |
clojurians | clojure | Ya, it might be overkill, and having all these different meta programming construct could get confusing and make things worse, but I'm having fun thinking about it :stuck_out_tongue: | 2017-11-17T17:06:45.000069 | Silas |
clojurians | clojure | sometimes a good answer is to make a macro that returns a function - the function captures your locals nicely and lets others pass in values | 2017-11-17T17:08:41.000126 | Margaret |
clojurians | clojure | it tends to elegantly solve the “I would use eval but it loses context” issues if you generate functions and pass in the locals | 2017-11-17T17:09:22.000072 | Margaret |
clojurians | clojure | Interestingly, it appears this is an old idea called FEXPRS, and people talk about it: <http://wiki.c2.com/?RuntimeMacro> and <https://en.wikipedia.org/wiki/Fexpr> | 2017-11-17T17:20:06.000011 | Silas |
clojurians | clojure | yeah, they are very very slow | 2017-11-17T17:20:16.000015 | Margaret |
clojurians | clojure | they mean you need interpreted instead of compiled code | 2017-11-17T17:20:25.000378 | Margaret |
clojurians | clojure | Ya, I can see that, as there is no way to know the order in which things will end up at runtime | 2017-11-17T17:22:40.000144 | Silas |
clojurians | clojure | I'll have to think about this | 2017-11-17T17:23:07.000430 | Silas |
clojurians | clojure | it looks like `(let [some-f (eval form-for-f)] (some-f local1 local2))` | 2017-11-17T17:24:56.000422 | Margaret |
clojurians | clojure | It appears that I can use a qualified keyword for a namespace that:
1. does not exist
2. exists in project, but is not yet loaded (to avoid circular dependency)
Are there any gotchas I should be aware of concerning these ? | 2017-11-17T17:57:29.000037 | Berry |
clojurians | clojure | The only "gotcha" I can think of is when you use something like `::alias/name` and it will depend on having the `alias` defined as an alias for the actual namespace qualifier. | 2017-11-17T18:00:31.000378 | Daniell |
clojurians | clojure | yeah and the errors from the alias not existing are terrible | 2017-11-17T18:01:37.000394 | Willow |
clojurians | clojure | copying aliased stuff into a ns without an alias throws like 5 reader errors in succession | 2017-11-17T18:02:08.000029 | Willow |
clojurians | clojure | ah, but since I'm not requiring the namespace (to avoid circular dependency), I'm doing :foo.bar/kw-name | 2017-11-17T18:02:48.000112 | Berry |
clojurians | clojure | I don't see where the `::alias/name` would show up | 2017-11-17T18:02:57.000270 | Berry |
clojurians | clojure | its if you explicitly use it | 2017-11-17T18:03:13.000192 | Willow |
clojurians | clojure | if everything is namespaced by `:Account/permissions` and `:Account/username` it can get a little tiring, and your code can get a little wide. So its nice to use
```
(create-ns 'HumanName)
(alias 'HN 'HumanName)
``` | 2017-11-17T18:04:23.000246 | Willow |
clojurians | clojure | Yeah, we have `ws.domain.member` and usually alias that to `m` so we have `::m/id` etc instead of `:ws.domain.member/id` | 2017-11-17T18:07:00.000258 | Daniell |
clojurians | clojure | I still do not understand how this applies to the current question, but when I run into this issue, I'll look back at this. | 2017-11-17T18:07:43.000083 | Berry |
clojurians | clojure | they are just gotchas with namespace qualified keywords | 2017-11-17T18:08:34.000054 | Willow |
clojurians | clojure | Does anyone know about any prior art re: using specs for autocomplete? e.g. I have a query language and an in-browser text box, `[:a :b :c (|)]` where `|` is the cursor, spec “knows” that there are only a handful of things that can meaningfully go there | 2017-11-17T19:02:27.000198 | Georgianne |
clojurians | clojure | the closest I’ve found is expound | 2017-11-17T19:02:31.000060 | Georgianne |
clojurians | clojure | maybe spec isn’t really the best tool for this since the set of answers can change at runtime there; I don’t necessarily know the full spec for the query language ahead of time, people can define their own helper rules | 2017-11-17T19:03:13.000087 | Georgianne |
clojurians | clojure | I know you have some core.logic experience, have you tried that? it seems like something like that would sort of be like type inference, like you want a list of possible things (|) could be, and there are constraints on what it could be based on what is around it (or just what precedes it) | 2017-11-17T19:15:10.000158 | Rebeca |
clojurians | clojure | <@Georgianne> <@Rebeca>: I was recently looking at a similar problem. Given 1. a CFG and 2 a prefix of a string ... what are all valid possible next-letter or next-2-letter or next-word combos?
Turns out, <https://en.wikipedia.org/wiki/Earley_parser> can handle that. | 2017-11-17T19:17:03.000103 | Berry |
clojurians | clojure | <@Rebeca> huh that’s an interesting suggestion; I hand’t considered that but sure I could probably hack together some HM type inference in core logic :slightly_smiling_face: | 2017-11-17T19:41:05.000007 | Georgianne |
clojurians | clojure | it just seems that spec _mostly_ has that information already but I guess maybe it doesn’t exactly | 2017-11-17T19:41:51.000084 | Georgianne |
clojurians | clojure | I am not sure spec would work directly, mainly because spec doesn't support partial parses(regardless of if you could get the information about what would complete the parse from the parser), but you might be able to walk a spec via s/form and generating the core.logic "typing" rules from it | 2017-11-17T19:43:42.000108 | Rebeca |
clojurians | clojure | Is there a reason to not use an Earley Parser? It can literally tell you what values are valid for next token. | 2017-11-17T19:46:50.000036 | Berry |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.