Warren Lynn | 21 May 23:21
Picon

Re: defrecord with "inheritance"

Sometimes it seems to me"OO" and "inheritance" have become some kind
of taboos. I don't believe OO is all that wrong. To me Clojure seems
to have good potential to harness the good part of OO without carrying
into the bad parts. So I am hoping. :-)

On May 21, 2:25 pm, "nicolas.o...@gmail.com" <nicolas.o...@gmail.com>
wrote:
> >> On the other hand, defrecord/deftype encourage you to write your protocol
> >> implementation in a way that cannot be reused unless you very specifically
> >> plan for it (factoring the protocol implementation into a separate map) and
> >> use a coding style that (might?) be less efficient (i.e., adding the
> >> protocol implementation via extend rather than directly in defrecord).  This
> >> is not so good and potentially limits the value of protocols for developing
> >> complex systems.
>
> Inheritance is bad because it ties code reuse to a (mostly)
> non-significant hierarchy.
> That is not a reason to prevent all code reuse from deftypes.
>
> (It is not because OO gets it wrong that we should not try)

--

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
(Continue reading)

Softaddicts | 21 May 18:48
Picon
Favicon
Gravatar

Re: defrecord with "inheritance"

The following is not about the merits of your request (or its foolishness :), it maybe a
taste issue.

If I look at productivity/efficiency, I cannot see the interest of sticking to the tools
and frameworks the majority is using presently. They are highly inefficients.

Doing things the same way they are already done and only changing the label
does not provide any gain whatsoever.

The heart of the problem is getting people to think differently about the things
they have been doing wrong for the last two decades.

I get regular feedback from people working in Javaish environments,
many criticize the methods and tools they use daily.
They feel they are not efficient and that it reduces their throughput significantly.

That uneasiness is a first important sign that something is wrong in the "natural"
thinking process of a significant chunk of developers (Java ones). Tools and
frameworks emerge from this "natural thinking".

I don't buy this idea of pleasing the majority but that maybe a personality trait.
It's not about selling Hygrade sausages, it's about questioning our "bad habits".

I got stuck into Java from back to 2001, my customers did not really questioned this 
choice in all  those years. 
They never realized the jail they were getting into. Now they know they
have a problem, having tons of code lines to maintain and no easy escape route.

Clojure is flexible enough to allow you to address the same problem in different
ways within a short timeframe. You can then experiment other approaches
(Continue reading)

Christian Guimaraes | 21 May 17:54
Picon

"when" function

Hi all,


I'm struggling with "when" code structures and my imperative mindset.

What is the better approach (or functional approach) to work with a code like the below?

(defn parse-group [group-identifier line]
  (when (= group-identifier "ID1")
    (handle-id1 line))
  (when (= group-identifier "ID2")
    (handle-id2 line))
  (when (= group-identifier "ID3")
    (handle-id3 line)))

Thank you.
-- christian


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Larry Travis | 21 May 06:51
Picon
Favicon

How do I set jvm options for a lein repl

How do I set jvm options for a lein repl initiated independently of a project?   In particular, I want the heap expansion that results from doing "M-x clojure-jack-in" in an emacs project.clj buffer with ":jvm-opts [ "-Xms4G" "-Xmx4G"]" in its defproject form.
  --Larry

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Mikera | 21 May 06:11
Picon

ANN: Clisk - Clojure image synthesis kit

Hello all,

You may be interested in my new project - a procedural image synthesis toolkit for Clojure. Designed for creating all kinds of patterns, textures etc.


Feel free to have a explore, comments / extra ideas welcome!

  Mike.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Warren Lynn | 20 May 19:22
Picon

defrecord with "inheritance"

So from what I read  the philosophy of Clojure discourages inheritance
on concrete data types. However, maybe I am too entrenched in my OO
thinking, how do I define a new record type that includes all the data
members of another record type? I am thinking about the classic
Employee/Person example.

If I can define a record of Employee with Person's data members
included, even that is not true inheritance (as no protocols of
"Person" will be automatically extended to "Employee"), I need that
for function re-use (so a function working on Person will
automatically work on Employee because Employee is guaranteed to have
all the data members in Person).

Also, again, maybe I am too OO minded, is there a way inherit another
record type's protocol implementation? That seems to give the best
combination of both worlds (OO and functional), so you can either have
you own very customized combination of data type/protocols, or use the
very common OO pattern. Just like we have both the single-typed
dispatching (which is more OO like and covers a large portion of use
cases), and more advanced multimethods.

Thanks.

--

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Moritz Ulrich | 20 May 13:29
Gravatar

ClojureScript: How to call console.log with variable args?


Hello,

I want to write a simple logging-wrapper around console.log, with the
background of being able to enable/disable logging at any time. This is
my current implementation:

--8<---------------cut here---------------start------------->8---
(defn log [& more]
  (.log js/console (apply pr-str more)))
--8<---------------cut here---------------end--------------->8---

This particuliar implementation is pretty nice (and awfully slow) for
Clojure data structures. It's unusablw for raw javascript data like
HTMLElements and other Objects with no reasonable implementation of
pr-str.

I want to print "raw" javascript objects using console.log and clojure
data using pr-str.

Doing this sort of switch should be easy, where I'm stuck is running
apply on console.log. I want to do something like:

--8<---------------cut here---------------start------------->8---
(apply (.-log js/console) (map ... args))
--8<---------------cut here---------------end--------------->8---

Which doesn't work. (I guess because console.log doesn't feature .call)

Can anyone point me in the right direction?

Cheers,

--
Moritz Ulrich

--

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Michael Erickson | 19 May 04:46
Picon

[Clojure Programming: Chapter 4] question about return form of `send`

Hello all,

I've been reading Clojure Programming by Emerick, Carper, and Grand from O'Reilly and have a question. 
Towards the end of Chapter 4, they implement a little web-crawler that uses agents.  I'm having some
trouble getting my head around one piece of the code.  Specifically the `run` function they define, which
I've pasted here: http://pastebin.com/EWqPaBPt.

In human terms, I understand this code to:

1) `send` a function "foo" to the agent to execute it (this will happen in another thread)
2) "foo" figures out the function "bar" to call to transition to the next state and calls it using either
`send` or `send-off` as appropriate
3) whatever "bar" happens to be, it is going to end with a call to run which will keep the wheels of the state
machine turning

So my question is regarding the return form of the outer send, which is `state`.  Is the idea here to basically
return the identity of the agent for this outer send?  Meaning, don't change anything this time, affect all
change via the inner send|send-off?

I know I can't really make this assumption, but to simplify for a moment, assume that these computations
took place in three separate threads; A, B, and C.

A: call `run`
    call send with "foo" (this will be executed in thread B)
    return immediately since agents are asynchronous

B: call "foo" with the agent
    "foo" calls send|send-off with "bar" (this will be executed in thread C)
    "foo" returns the agent as it was when it was called, so it's only real purpose was to get "bar" going.

C: call "bar" with the agent
     this is where we actually do work and change the state of the agent
     call `run`

Am I on the right track?

Best regards,
--mike

Michael Erickson
erickson.michael <at> gmail.com

--

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Edward Ruggeri | 20 May 05:18
Gravatar

Clojure for shell scripts

Hey everyone!,

I know this is an old story.

I've played with clojure, but the main thing that has kept me from
never looking back is the startup speed.  "Hello world!" in Java takes
me .303s, but just "java -cp clojure-1.5.0-master-SNAPSHOT.jar" takes
1.989s (sending C-d to close the repl even before it starts).
Searching around here, I've found -XX:+TieredCompilation knocks me
down to 1.581s and also
-Xbootclasspath/a:clojure-1.5.0-master-SNAPSHOT.jar all the way to
0.938s.

Incidentally, the same tricks with "Hello World" take me to 0.159s.

Those were major improvements with very little cost; a huge win
(thanks clojure list!).  Any further easy tips and tricks?  I'd like
to get to the point where shell scripts aren't painful.  It looks like
other major hints are nailgun, and never restarting the repl during
development.

I took the liberty of printing some System.getCurrentMillis from
clojure.main.  It looks like it takes me 0.666s to enter the
clojure.main main method, which I didn't entirely expect.  There are
several static members of clojure.main that need to be initialized,
these members take ~.520s to initialize in total; almost all of this
is initializing `Var REQUIRE`.  Presumably this is when most of the
clojure environment starts to get loaded?

I'm just starting to look into clojure's jvm implementation; does
anyone have some pointers on how to get quickly up to speed with the
internals of clojure?

Thanks!,

-- Ned Ruggeri

--

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Brent Millare | 19 May 22:27
Picon

core.logic, comparators

I understand how to construct goals using the primitives provided in core.logic, like a conjunction with fresh or all, and using relations defined with defrel. However, I don't really understand the protocols of goals once I no longer use these primitives.


How would I define my own comparison like function? Instead of unifying, I'd like to do a comparison.

Something like this:

...

(l/fact person :bob 3)
(l/fact person :april 2)

(l/run 5 [q]
    (l/> q 2)
    (l/fresh [name]
        (person name q)))
(3)

What would be the definition for l/>?

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
Alex Robbins | 19 May 20:12
Picon
Gravatar

Core.logic, dynamically generated goals

I'm just getting started with logic programming, and it is entirely
possible I'm just approaching this incorrectly.

Is it possible to use dynamically generated goals in run* ?

For example,

(defrel grade person course g)
(fact grade 'Bob 'Algebra 'B)
(fact grade 'Bob 'Art 'C)
(fact grade 'John 'Algebra 'A)
(fact grade 'John 'Art 'A)
(fact grade 'Ricky 'Algebra 'D)
(fact grade 'Ricky 'Art 'A)

(def knowledge
  {:course 'Algebra :g 'B})

(defn generate-goals [knowledge]
  (map
    (fn [{:keys [course g]}] (list 'grade 'person course g))
    knowledge))

I want to do something like this (but valid clojure):
(run* [person]
  ~@(generate-goals knowledge))

It should give me back a list of people who match my current
knowledge. If I have more knowledge about the person, it will generate
more conditions, less knowledge fewer conditions. However, since run*
and run are macros, I can't apply them to a list. I can't splice in
because I'm not in a quotes list. Any ideas?

Thanks!

--

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure <at> googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe <at> googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Gmane