Fork me on GitHub
#off-topic
<
2018-05-28
>
prnc08:05:31

@phil672 from the sound of it tangle might be what you're looking for: https://orgmode.org/manual/tangle.html

Philip Hale09:05:50

Thank you, that's interesting....the problem with tangle I think is that it gives the org-mode primacy, I was hoping for more of an import-from-file rather than export-to-file. I think my best bet actually is for the org code blocks to read the clojure as data, and then print the output:

#+begin_src clojure :results output
  (clojure.repl/source )
#+end_src

benzap08:05:30

I wrote a blog post on something that i've been developing. An embeddable scripting language. http://benzaporzan.me/blog/2018/5/28/fif__an_introduction/

💯 4
benzap08:05:58

Feedback welcome, i'm going to post a reddit post in a bit

akiroz10:05:48

Wow, that's really cool! I haven't seen a stack language since... postscript xD

cvic11:05:52

Yep. Looks great

vemv16:05:20

user=> (+ "a")
ClassCastException Cannot cast java.lang.String to java.lang.Number  java.lang.Class.cast (Class.java:3369)
Wondering if a better message would be ClassCastException Cannot cast java.lang.String ("a") to java.lang.Number i.e. inline the faulty value, instead of making me find the right file/line to jump to, and place a debugging statement accordingly

vemv16:05:26

Anything I can do about it?

borkdude16:05:04

@vemv error messages in clojure are a controversial subject

borkdude16:05:35

@vemv if you really want to have a more useful error message you might want to use clojure.spec + expound. maybe there is already a core spec for +, if not, write it yourself

vemv16:05:35

Yeah that would be the conventional wisdom these days... wondering if I can cheat a little 🙂

borkdude16:05:53

you can catch the exception and then do something with it

vemv16:05:53

Doing it at clojure.core level seems tempting (and it works), that way I get debug info even when I wasn't expecting a ClassCastException (and therefore my code wasn't wrapped with try/catch)

(def cce-culprit (atom nil))

(alter-var-root #'clojure.core/cast
                (constantly (fn [^Class c x]
                              (try
                                (. c (cast x))
                                (catch ClassCastException e
                                  (reset! cce-culprit x)
                                  (throw e))))))
Could be a nice dev-env-only addition in my projects.

borkdude16:05:32

Does that work? I think clojure is compiled with direct linking

vemv16:05:01

Good point but I see it working in the repl

alexmiller16:05:39

+ is inlined and you can’t instrument specs on inlined functions

👍 1
alexmiller16:05:56

Because you don’t go through the var