Fork me on GitHub
#clojure
<
2019-05-07
>
quadron09:05:16

is there something like the inverse of "->" out there? a macro that takes a nested lisp expression and a symbol and returns it in threaded form?

hkjels11:05:24

I’m having a hard time contemplating what you mean. Could you elaborate? Maybe some pseudo-code would help

lilactown15:05:42

I don’t think this is a normal thing, but you could try writing one :D

quadron17:05:29

clj-refactor seems to be what I'm looking for

Anthony Ciacci13:05:41

Hello! I'm taking a new job and going back to Rails land from Clojure world. I'm a little sad to leave functional programming, and would like to maintain some of the fp mindset, so if anyone knows any good resources/blogs that discuss what fp concepts work well for OO codebases and how best to apply them, I would greatly appreciate it 🙏

raaon16:05:59

Anthony, sad to see a Clojurist lost to Rails : ) Take a look at, which begins by outlining a Ruby path from OO to functional way of thinking: https://medium.com/@aarontdixon/dynamic-validations-in-rails-8019570f9c59

souenzzo17:05:14

How do I access "this" inside toString ? And how to control the creation of the instance?

(.toString (proxy [PersistentArrayMap] []
             (toString []
               "42")))

noisesmith17:05:51

that empty vector is the list of args to the superclass constructor

noisesmith17:05:24

@souenzzo there's an implicit this you can access

user=> (str (proxy [Object] [] (toString [] (clojure.string/reverse (str (supers (class this)))))))
"}tcejbO.gnal.avaj yxorPI.gnal.erujolc{#"

👍 4
noisesmith17:05:48

there's also proxy-super for delegating to the superclass explicitly

user=> (str (proxy [Object] [] (toString [] (clojure.string/reverse (proxy-super toString)))))
"b94e08c1@a47291ff$tcejbO.gnal.avaj$yxorp.resu"

👍 4
noisesmith18:05:44

good to know, thanks

souenzzo19:05:23

let's vote

Alex Miller (Clojure team)17:05:13

the this in proxy is the only "magic" anaphoric macro symbol in clojure I think

noisesmith17:05:40

:>> in condp feels like a cousin of that

Alex Miller (Clojure team)17:05:27

a little, but all keywords evaluate to themselves, so no issue there (vs symbols which evaluate to something else)

👍 4
noisesmith17:05:46

yeah - not the same thing, just a similar "magic" feeling

noisesmith17:05:58

also marginal cases: catch, finally, inside try, and thrown? and thrown-with-message? inside clojure.test/is

noisesmith18:05:13

in that they are not bound anywhere, but they have meaning implemented by a parent macro

respatialized19:05:09

I'm reading about core.spec and I came across one passage in the design rationale that I'm having trouble understanding. > Invariably, people will try to use a specification system to detail implementation decisions, but they do so to their detriment. The best and most useful specs (and interfaces) are related to purely information aspects. What's an example of "trying to use a specification system to detail implementation decisions?", as contrasted with a purely informational use of a spec?

Alex Miller (Clojure team)19:05:14

spec'ing intermediate internal functions

Alex Miller (Clojure team)19:05:57

or like some of the specs for clojure.core that people have written fall into this

Alex Miller (Clojure team)19:05:25

they look at exactly what a function currently implements and spec that, which may eliminate things that will be supported in the future

Alex Miller (Clojure team)19:05:40

clojure core functions are aggressively polymorphic and we continue to add cases over time - spec'ing that stuff is a form of unnecessarily reducing future options

respatialized20:05:13

That's what I thought it might be, but I was having trouble putting it into the right words. So I guess using spec for "implementation decisions" would be arbitrarily limiting what you can pass to or return from a function so that a given spec is always satisfied.

respatialized20:05:58

so it seems like from the rest of that passage that spec is most useful at the edges of a program - informing and adding context to what other programs can send to or get from the program which uses spec.

Alex Miller (Clojure team)20:05:43

certainly focused on the the functions that consume, transform, and emit maps of attributes