Fork me on GitHub
#beginners
<
2019-06-16
>
dumrat06:06:01

Hi guys, Reading this: https://clojure.org/about/functional_programming Regarding tail-calls, it says this:

While not as general as tail-call-optimization, it allows most of the same elegant constructs, and offers the advantage of checking that calls to recur can only happen in a tail position.
What does it mean when it says that recur is not as general as tail-call-optimization? Any examples?

andy.fingerhut06:06:37

A full implementation of tail call optimization would optimize a tail call to function foo, a call to foo that was inside of function bar, into a "jump".

👍 4
andy.fingerhut06:06:46

Clojure's recur cannot do that.

dumrat06:06:18

So, can I understand that unless there is a mutual recursion scenario, recur is as good as TCO?

andy.fingerhut06:06:47

Full tail call implementations optimize to jumps whether there is mutual recursion or not.

andy.fingerhut06:06:57

recur is as good as TCO for self calls only.

👍 4
dumrat06:06:39

Ok. Got it. Thank you

andy.fingerhut06:06:53

Self calls are one of the most common cases where TCO is helpful, so recur covers that most common case.

Ho0man08:06:11

Hi everyone, How can I read a custom byte array type as string ? like this one : #object[com.rabbitmq.client.impl.LongStringHelper$ByteArrayLongString 0x4cb2ccf3 "OrderNotice" I want to extract the string "OrderNotice" as plain String. Thanks in advance

valerauko08:06:23

my first try would be the byte-streams lib

hiredman15:06:43

You can likely get the string you want just calling str on the object

hiredman15:06:24

By default the way the prints objects is #object[class-name identity-hash to-string]

hiredman15:06:04

to-string being the result of calling the toString method on the object

hiredman15:06:38

The str function will call the toString method for you

Ahmed Hassan17:06:24

Have anyone used Ant Design Mobile with Reagent and Re-frame? I want to build wrapper like Antizer for Ant Design Mobile. What are API similarities between Ant Design and Ant Design Mobile?

vlad_poh17:06:26

Hi my fellow clojurians. How do i keep my jetty ring based app up and running at all times?

jumar18:06:26

What do you mean by that? It's likely the same as for any other process - depends on OS and deployment environment, I guess; you could use systemd, docker, etc.

johnj20:06:43

When I call dev from the user ns using this:

(ns user)

(defn dev []
  (require 'dev)
  (in-ns 'dev)
  (set! *print-namespace-maps* false))

johnj20:06:16

print-namespace-maps is still set to true, what I'm missing?

johnj20:06:04

do I need to rebind it?

hiredman22:06:43

That likely throws an exception, and that isn't how namespaces and vars work

hiredman22:06:09

Symbols are resolved once at compile time to a var in a namespaces, but you are trying to effect symbol resolution by changing namespaces at runtime

johnj23:06:48

@hiredman that actually worked (from the repl), my issue was somewhere else but I'll keep that in mind