This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-22
Channels
- # aws (5)
- # bangalore-clj (3)
- # beginners (84)
- # boot (31)
- # carry (1)
- # cider (6)
- # cljsrn (7)
- # clojure (188)
- # clojure-conj (1)
- # clojure-dev (3)
- # clojure-dusseldorf (8)
- # clojure-greece (10)
- # clojure-italy (7)
- # clojure-nl (3)
- # clojure-russia (45)
- # clojure-spec (5)
- # clojure-uk (64)
- # clojurescript (83)
- # clr (9)
- # core-async (45)
- # cursive (55)
- # datomic (8)
- # devops (1)
- # emacs (7)
- # graphql (1)
- # hoplon (3)
- # jobs (1)
- # jobs-discuss (37)
- # lein-figwheel (3)
- # leiningen (4)
- # luminus (6)
- # off-topic (5)
- # om (2)
- # onyx (33)
- # pedestal (13)
- # re-frame (9)
- # reagent (28)
- # rum (15)
- # specter (4)
- # unrepl (38)
- # vim (3)
a message of "foo cannot be cast to clojure.lan.IFn" means that somewhere in your code you have a foo in parens
notice ((let ...))
your function is returning a string from the let, and then trying to call the string
also, truthy? can be replaced by another function that already exists, called identity
@vitruvia there's things you eventually know to look out for
((...)) is pretty much always suspicious to me
I mean, sometimes I directly use a function that returns another function, but that's not the normal way to do things
and the error messages - as soon as I see "cannot be cast to IFn" I look for extra parens, because that's what that message pretty much always means
right, (x) means x needs to be a function
that error is saying "hey, x isn't a function, it's a String"
false
or nil, that would work too
a common way to do that would be ::falsey - which is a keyword namespaced to the current namespace
which indicates that it belongs to, or is particularly relevant to, that namespace
@vitruvia a good editor/plugin can help as well - I've used parinfer for visual studio code, and currently use the emacs setup that Brave Clojure offered
hopefully it will help, but for this intro course that I'm doing I`ll finish with lighttable
if something wants you to return "falsey" you should return false or nil
I've got some semi-colons in a string
How do I have it register as a semi-colon and not a comment...
@grounded_sage how did you get semicolons in a string to register as a comment?
@akiroz I'm doing :dangerouslySetInnerHTML
in Rum. Got some embed code from another website and just pasted it in. It's registering it as a comment and completely messing up the embed lol. The semicolon is for the style tags
[:div { :dangerouslySetInnerHTML {:__html
"<div class=\"typeform-widget\" data-url=\"https://wade93m.typeform.com/to/bmlrGC\"
style="width: 100% =>}}]; height: 500px;" > </div> <script> (function() { var qs,js,q,s,d=document, gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm", b=" "; if(!gi.call(d,id)) { js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script> <div style="font-family: Sans-Serif;font-size: 12px;color: #999;opacity: 0.5; padding-top: 5px;" > powered by <a href="https://www.typeform.com/examples/surveys/?utm_campaign=bmlrGC&utm_source=typeform.com-393933-Basic&utm_medium=typeform&utm_content=typeform-embedded-onlinesurvey&utm_term=EN" style="color: #999" target="_blank">Typeform</a> </div>"}}]
The problem is thet the ;
comments out the rest of the line
I started commenting them but didn't go into the commented out pieces. THANKS!
create table forums( id int auto_increment primary key, name varchar(50) not null, description varchar(250), ownerUsername varchar(30) not null, -- owner creationDate datetime not null, -- creation date locked boolean not null, type varchar(30) not null, parentForumId int, -- nadforum, deleted boolean not null, FOREIGN KEY (ownerUsername) REFERENCES users(username), FOREIGN KEY (parentForumId) REFERENCES forums(id) );
i wanna make statement or function that would delete all children if parent is 'deleted' (deleted set to 1 )
i wrote java function that recursively asks for ids of all children deletes rows with those ids and repeats proces till null (root is found)
Having a hard time with sente + component system. Whenever I try to send an event from the client to the server, I get "Chsk send against closed chsk." Do I need to wait for a state update from the server? Is my socket not connecting properly? I seem to be getting events from the server, I just can't send from the client.
Hi everyone! Just a quick question. I am using org-mode
to do some literate programming. Is there a way for me to take a code block and paste it into my repl easily?
@gekkostate other than mark
the region and kill-ring-save
?
@petrus it’s possible to check the state of the socket from the client. In my app I run a block of core.async code that captures messages instead of sending them until the connection is confirmed active, then it sends the backlogged messages
usually it’s just a question of pausing message sends until the the socket is established -it should be a short lived state
Random brain fart: am I right in suddenly realising that def
and ns
are super weird? By that I mean they are fundamentally mutable in nature (they directly modify "global state"), counter to virtually everything else in Clojure?
@deactivateduser10790 That's correct. The top level is pretty much your typical lisp, fully modifiable repl environment.
Immutable namespaces would be an interesting exercise. I think some folks tried it. Didn't get much traction. Not sure why. Might be a lot of complexity.
Cool! Yeah namespaces are weird anyway - coming from a Java background it does my head in that they're not just a compile-time construct.
(i.e. more akin to Java packages)
It's just that in most repling situations, you want to re-def things, so as to test different things.
Yeah - don't get me wrong, I love being able to def
the same var as many times as I need while experimenting.
I guess it's probably a rather bad practice to do that in library code though.
e.g. using def
within an fn.
yeah, once the namespace is written, you generally don't want dynamic constructs mutating that namespace. So Clojure allows you to enjoy the benefits of both worlds, sort of.
@deactivateduser10790 on the other hand, def, defn, etc. are just macros. nothing wrong with writing your own def-like macros in your lib.
@mobileink yeah, though I have a hard time coming up with a scenario where I'd do that vs, say, just having a (def ^:private my-mutable-state (atom ...))
that I mutate within a public fn using swap!
.
atoms seem like the "safe" way to do this kind of thing, vs (ab)using def
.
metaprogramming is my use case. my deffoo macros add private metadata to the var (among other things), so they behave just like clojure constructs, but my tools can do devious things with them.
@deactivateduser10790 right - don’t use namespaces / vars as data structures, if you need to create or update data at runtime use one of clojure’s nice concurrent mutable containers like atom or ref
and sure, put that atom or ref inside a def, namespaces are nice to use from code