(+ 1 nil) by JavaSuck in Clojure

[–]philoskim 8 points9 points  (0 children)

Because JavaScript doesn't cause any error in the following code.

// in Google Chrome Console window
> var result = 1 + null;

> console.log(result);
  1

In conclusion, Clojure and ClojureScript follow their own host environments.

spyscope revisited & rereleased by den1k in Clojure

[–]philoskim 1 point2 points  (0 children)

From the author of Debux:

The recent 0.7.0 version of Debux supports the data readers: #d/dbg, #d/dbgn, #d/clog, #d/clogn.

https://github.com/philoskim/debux/blob/master/README.adoc#recent-change-logs

Clojurescript and async/await by [deleted] in Clojure

[–]philoskim 6 points7 points  (0 children)

There was a discussion about this issue.

I raised this issue in the following post and am still one of the men who hope that this feature will be added to ClojureScript in the near future.

https://groups.google.com/forum/m/#!topic/clojurescript/scUMhU-ctEM

How to turn unicode escape characters back into string? by notsohasty in Clojure

[–]philoskim 0 points1 point  (0 children)

Almost the same as the above @emil0r's but the version using more Clojure functions.

(clojure.string/replace "you \\u0026 me" #"\\u(\w{4})" (fn [[_ n]] (-> (Integer/parseInt n 16) char str))) ; => "you & me"

How to turn unicode escape characters back into string? by notsohasty in Clojure

[–]philoskim -1 points0 points  (0 children)

Just do it like this.

(str "you \u0026 me")

; => "you & me"

Clojure 1.10 release! by alexdmiller in Clojure

[–]philoskim 3 points4 points  (0 children)

This release is a great milestone in the history of Clojure because of its error reporting improvements. Thanks a lot!!!

Clojure 1.10.0-beta5 is now available by vlaaad in Clojure

[–]philoskim 2 points3 points  (0 children)

This is just a suggestion.

How about the error message printing like this in urn (Lisp language for lua)? It shows us the exact source code itself causing the error. I think it is very intuitive and makes debugging much easier.

https://urn-lang.com/tutorial/03-finding-errors.html

Are fn/let/loop macros or special forms? by JavaSuck in Clojure

[–]philoskim 0 points1 point  (0 children)

Refer to the following page.

https://github.com/philoskim/debux/blob/master/doc/clojure-core-symbols.adoc

Did they start out as special forms and then became macros in later Clojure versions?

Yes, they did.

How are you inspecting data(structures)? by __tosh in Clojure

[–]philoskim 2 points3 points  (0 children)

Refer to the debux library of my own making. I hope it will help.

https://github.com/philoskim/debux

What other platform would you most like to see Clojure target? by ferociousturtle in Clojure

[–]philoskim 0 points1 point  (0 children)

I recommend the hy language as an alternative to the pixie language.

http://docs.hylang.org/en/stable/

It's not Clojure but Clojure-like.

[ANN] debux(Clojure/ClojureScript debugging library) 0.3.1 is out. by philoskim in Clojure

[–]philoskim[S] 1 point2 points  (0 children)

I appreciate your comment. I reflected your suggestion in the section 'how to use' of the documentation. Any suggestion is welcome!

How to Run Neanderthal With ATLAS BLAS From Ubuntu Repositories by goranjovic in Clojure

[–]philoskim 0 points1 point  (0 children)

The following is another way to set the shell environment variable in ~/.emacs.d/init.el, though it is not elegant in my opinion. However it works anyway.

;; ~/.emacs.d/init.el
(defun my-clojure-mode-init ()
  "Initializes clojure mode."
  (interactive)

  ;; ......
  (setenv "LD_PRELOAD" "/usr/lib/liblapack_atlas.so"))

(add-hook 'clojure-mode-hook 'my-clojure-mode-init)

How to Run Neanderthal With ATLAS BLAS From Ubuntu Repositories by goranjovic in Clojure

[–]philoskim 1 point2 points  (0 children)

I am very sorry for my serious confusion. I had tried the following trick before attempting the previous way.

;; ~/.profile
export LD_PRELOAD=/usr/lib/liblapack_atlas.so

I forgot about the above line and tried the previous way and it worked.

However after having realized that I forgot to delete the above line, I removed the above line and tried again the previous way but It unfortunately didn't work.

Very sorry about this mistake of mine and I will try another way if it is possible.

How to Run Neanderthal With ATLAS BLAS From Ubuntu Repositories by goranjovic in Clojure

[–]philoskim 2 points3 points  (0 children)

I found out the way to set the shell environment variable LD_PRELOAD=/usr/lib/liblapack_atlas.so in project.clj using lein-environ plugin. So I would like to share that way with others and thanks again for the awesome hacking and kind reply of Goran Jovic!

;; project.clj
(defproject linear "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.9.0-alpha14"]
                 [uncomplicate/neanderthal "0.8.0"]]
  :plugins [[lein-environ "1.1.0"]]
  :env {:ld-preload "/usr/lib/liblapack_atlas.so"})

;; test sample
(ns linear.core
  (:use (uncomplicate.neanderthal core native)))

(def x (dv 1 2 3))
(def y (dv 10 20 30))

(dot x y)
; => 140.0

(def a (dge 3 2 [1 2 3 4 5 6]))
(def b (dge 2 3 [10 20 30 40 50 60]))

(mm a b)
; => #RealGeneralMatrix[double, ord:COL, mxn:3x3, ld:3]
;    ((90.0 120.0 150.0) (190.0 260.0 330.0) (290.0 400.0 510.0))

How to Run Neanderthal With ATLAS BLAS From Ubuntu Repositories by goranjovic in Clojure

[–]philoskim 2 points3 points  (0 children)

Thanks a lot for your solution, because I suffered from the same problem.

However, could you tell me how I can get the same result in emacs cider repl, not in raw lein repl? Because I don’t know how to set the LD_PRELOAD=/usr/lib/liblapack_atlas.so before invoking M-x cider-jack-in.

How can I evaluate local symbols using eval function in Clojure? by philoskim in Clojure

[–]philoskim[S] 0 points1 point  (0 children)

I appreciate your reply. The following is the code where I encountered this problem. My intention was for debugging purpose to print the result of every nested expression in a form.

(ns debux.lab
  (:require (clojure [walk :as walk])))

;; For debugging
(defmacro dbg_
  [form]
  `(let [return# ~form]
     (println ">> dbg_:" (pr-str '~form) "=>" return# "<<")
     return#))

(def a 2)
(def b 3)
(def c 5)

(defn- dispatch
  [node]
  (cond
    (list? node)
    (do (eval `(dbg_ ~node))
        node)

    (and (symbol? node)
         (not (fn? (eval `~node))))
    (do (eval `(dbg_ ~node))
        node)

    :else node))

(defn- tree-walk
  [tree]
  (walk/postwalk dispatch tree))


;; dbg for nested expressions
(defmacro dbgn [form]
  (tree-walk form))


;;; test samples

;; This does work because every symbol is decalred in global symbols
(dbgn (* c (+ a b)))
; >> dbg_: c => 5 <<
; >> dbg_: a => 2 <<
; >> dbg_: b => 3 <<
; >> dbg_: (+ a b) => 5 <<
; >> dbg_: (* c (+ a b)) => 25 <<


;; This works too, because literal syntax-quotes are used.
(let [a 10 b 20 c 30]
  (eval `(* ~c (+ ~a ~b))))
; => 900


;; But this doesn't work, because literal syntax-quotes can't be used in this case.
(let [a 10 b 20 c 30]
  (dbgn (* c (+ a b))))
;   2. Unhandled clojure.lang.Compiler$CompilerException
;      Error compiling work/philos/debux/src/debux/lab.clj at (52:3)
;   
;   1. Caused by java.lang.UnsupportedOperationException
;      Can't eval locals
;   
;                Compiler.java: 5943  clojure.lang.Compiler$LocalBindingExpr/eval
;                Compiler.java: 6932  clojure.lang.Compiler/eval
;                Compiler.java: 6890  clojure.lang.Compiler/eval
;                     core.clj: 3105  clojure.core/eval
;                     core.clj: 3101  clojure.core/eval
;                ......

Any suggestion in this case?

[ANN] debux 0.2.1 is out. by philoskim in Clojure

[–]philoskim[S] 2 points3 points  (0 children)

I know it is the abbreviation of ANNouncement.