Re: Doseq, map-style

2012-06-18 Thread Softaddicts
The protocol profile describes the data items, their attributes and where they fit in the overall structure. The DSL is there to encode the representation from a human readable format It's not per se specific to the medical field, the same trick could be used for other standard business protocol

Re: Doseq, map-style

2012-06-18 Thread Kurt Harriger
On Jun 18, 2012, at 5:35 PM, Softaddicts wrote: > Lets talk a bit about my world here. > > We created a product to link medical equipments > using a variety of protocols, some talk HL7, DICOM, others have proprietary > means to > access data from various places. > > From the start we chose the r

Re: Doseq, map-style

2012-06-18 Thread Softaddicts
Lets talk a bit about my world here. We created a product to link medical equipments using a variety of protocols, some talk HL7, DICOM, others have proprietary means to access data from various places. >From the start we chose the richest data representation, some of it came from a few medical

Re: Doseq, map-style

2012-06-18 Thread Kurt Harriger
On Monday, June 18, 2012 8:01:47 AM UTC-6, tbc++ wrote: > > > Isnt that just creating an api? Everywhere the old model exists you need > to > > call a function to create the desired data structure and this adds > another > > layer of complexity that needs maintained. Not all conversions are

Re: Doseq, map-style

2012-06-18 Thread Kurt Harriger
I did not know about lazy map either… This might be exactly what I was needed. Maps with referentially transparent properties rather than fields. A way to make minor changes to map representation without adding an api in advance, introducing breaking changes, redundant properties, or conver

Re: Doseq, map-style

2012-06-18 Thread Jim - FooBar();
I wan't aware of LazyMap! My solution so far was to attach functions instead of values in maps. You 're still deferring the computation to the underlying fn...in a sense it is a getter isn't it? and you can also pass the map around to effectively get polymorphic behaviour on the fns that accept

Re: Doseq, map-style

2012-06-18 Thread Vinzent
Yeah, I'm waiting for concrete example too. By the way, if you really need to change :area from value to deferred computation then you can just change your data structure implementation from hash-map to lazy map (i.e. a map whose values are delays deref'd on access). This would require changing

Re: Doseq, map-style

2012-06-18 Thread Christophe Grand
On Mon, Jun 18, 2012 at 3:37 PM, Kurt Harriger wrote: > > Representations are values in Clojure, they are not mixed with behaviors > like in mainstream OO. It follows that, if your representation need to > change, you can write a converter function (or two if you want to convert > from and to the

Re: Doseq, map-style

2012-06-18 Thread Timothy Baldridge
> Isnt that just creating an api? Everywhere the old model exists you need to > call a function to create the desired data structure and this adds another > layer of complexity that needs maintained.  Not all conversions are straight > forward, may require additional context of whatever introducing

Re: Doseq, map-style

2012-06-18 Thread Kurt Harriger
On Jun 18, 2012, at 2:09 AM, Christophe Grand wrote: On Sun, Jun 17, 2012 at 8:59 PM, Kurt Harriger wrote: > > Data structure is an implementation detail... >> > > It's not. Not in clojure. It is in OO, but clojure is not an OO language, > so it's not an implementation detail in clojure. > > > T

Re: Doseq, map-style

2012-06-18 Thread Christophe Grand
On Sun, Jun 17, 2012 at 8:59 PM, Kurt Harriger wrote: > > Data structure is an implementation detail... >> > > It's not. Not in clojure. It is in OO, but clojure is not an OO language, > so it's not an implementation detail in clojure. > > > That is my point, representations SHOULD be considered i

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
On Jun 17, 2012, at 9:46 PM, Sean Corfield wrote: > On Sun, Jun 17, 2012 at 8:06 PM, Kurt Harriger wrote: >> One of the sayings I hear reiterated is "it is better to have 100 methods >> that operate on one data structure than 10 methods that operate on 10 data >> structures." Yet how is this di

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
On Jun 17, 2012, at 9:38 PM, Timothy Baldridge wrote: >>> I have also found that clojure code lacks cohesion we hate objects so we >>> are just going to throw everything into one large namespace and say we have >>> none... In OO I might call this a god class? I don't know, I'm not sold >>> ye

Re: Doseq, map-style

2012-06-17 Thread Sean Corfield
On Sun, Jun 17, 2012 at 8:06 PM, Kurt Harriger wrote: > One of the sayings I hear reiterated is "it is better to have 100 methods > that operate on one data structure than 10 methods that operate on 10 data > structures."  Yet how is this different from one large interface with a > hundred methods

Re: Doseq, map-style

2012-06-17 Thread Timothy Baldridge
>> I have also found that clojure code lacks cohesion we hate objects so we are >> just going to throw everything into one large namespace and say we have >> none... In OO I might call this a god class? I don't know, I'm not sold >> yet... but I'll keep watching. That depends. In OOP we might

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
On Sunday, June 17, 2012 6:31:34 PM UTC-6, Sean Corfield wrote: > > On Sun, Jun 17, 2012 at 11:59 AM, Kurt Harriger > wrote: > > That is my point, representations SHOULD be considered implementation > > details, because representations change... if you treat them as > contracts > > your cod

Re: Doseq, map-style

2012-06-17 Thread Sean Corfield
On Sun, Jun 17, 2012 at 1:32 PM, Kurt Harriger wrote: > If you follow the > hollywood principle you don't need getters... but you do need side-effects. This might be where you're getting stuck then? Perhaps "the hollywood principle" isn't the best approach? If you think it really requires side-ef

Re: Doseq, map-style

2012-06-17 Thread Sean Corfield
On Sun, Jun 17, 2012 at 11:59 AM, Kurt Harriger wrote: > That is my point, representations SHOULD be considered implementation > details, because representations change... if you treat them as contracts > your code will break everywhere, if you wrap them with abstractions your > code will only nee

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
On Sunday, June 17, 2012 1:41:22 PM UTC-6, Vinzent wrote: > > That is my point, representations SHOULD be considered implementation >> details, because representations change... if you treat them as contracts >> your code will break everywhere, if you wrap them with abstractions your >> code w

Re: Doseq, map-style

2012-06-17 Thread Softaddicts
Your first lisp ? I suggest you immersed yourself in it. Clojure is my third. Clojure is different from past languages because it allows features that have existed for a number of years separately to coexist together nicely. Many languages in the past have been created based on a couple of these

Re: Doseq, map-style

2012-06-17 Thread Vinzent
> > That is my point, representations SHOULD be considered implementation > details, because representations change... if you treat them as contracts > your code will break everywhere, if you wrap them with abstractions your > code will only need to change in one place... > As I mentioned ab

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
Sent from my iPhone On Jun 17, 2012, at 12:43 PM, Vinzent wrote: Data structure is an implementation detail... > It's not. Not in clojure. It is in OO, but clojure is not an OO language, so it's not an implementation detail in clojure. That is my point, representations SHOULD be considered im

Re: Doseq, map-style

2012-06-17 Thread Vinzent
> > Data structure is an implementation detail... > It's not. Not in clojure. It is in OO, but clojure is not an OO language, so it's not an implementation detail in clojure. > interfaces are contracts, if the data representation changes in OO you > need only change one class... > Well, bu

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
On Jun 17, 2012, at 10:45 AM, Vinzent wrote: Yes it is... emails was not the best example in this case.. think the > "area" example instead as this is single value rather than collection. > Well, I thought we've already came to the agreement that area is a (polymorphic) function and it has nothi

Re: Doseq, map-style

2012-06-17 Thread Vinzent
> > Yes it is... emails was not the best example in this case.. think the > "area" example instead as this is single value rather than collection. > Well, I thought we've already came to the agreement that area is a (polymorphic) function and it has nothing to do with structure of your data,

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
On Sunday, June 17, 2012 9:09:23 AM UTC-6, Vinzent wrote: > > This still requires changing your code to @(:emails contact). If you use (emails contact) you need change your code in only one place. >>> > The name "emails" implies that it's a sequence. Lazy sequence. > Yes it is... e

Re: Doseq, map-style

2012-06-17 Thread Kurt Harriger
On Sunday, June 17, 2012 8:48:58 AM UTC-6, Vinzent wrote: > > Well, if those assertions are violated, you can't do anything with it > anyway - you program is written wrong and you have to release new version > which'll fix it. > Yes, but if data in your database become corrupt then you may nee

Re: Doseq, map-style

2012-06-17 Thread Vinzent
> > A really good clojure specific example of data vs api is the discussion >> regarding if the clojurescript analyzer should contain children or if >> children should be a multimethod >> https://groups.google.com/forum/m/?fromgroups#!topic/clojure-dev/vZLVKmKX0oc > > By the way, I have read t

Re: Doseq, map-style

2012-06-17 Thread Vinzent
> > This still requires changing your code to @(:emails contact). If you use >>> (emails contact) you need change your code in only one place. >>> >> The name "emails" implies that it's a sequence. Lazy sequence. > Property is just the OO word for function, semantically they are the same.

Re: Doseq, map-style

2012-06-17 Thread Vinzent
Well, if those assertions are violated, you can't do anything with it anyway - you program is written wrong and you have to release new version which'll fix it. воскресенье, 17 июня 2012 г., 1:41:17 UTC+6 пользователь Alex Baranosky написал: > > To test for violations of those assertions, possi

Re: Doseq, map-style

2012-06-16 Thread Kurt Harriger
On Jun 16, 2012, at 6:27 PM, Softaddicts wrote: > 50 years of solid programming principles, OO being the Holy Grail ? :) > > I assume then that you programmed a lot in Simula-66 ? I did... > > For over 50 years, we made the same mistakes that Clojure attempts to > correct. Most of the time new la

Re: Doseq, map-style

2012-06-16 Thread Softaddicts
50 years of solid programming principles, OO being the Holy Grail ? :) I assume then that you programmed a lot in Simula-66 ? I did... For over 50 years, we made the same mistakes that Clojure attempts to correct. Most of the time new languages repackaged the same flawed concepts of the past, thi

Re: Doseq, map-style

2012-06-16 Thread Kurt Harriger
-- Kurt Harriger Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Saturday, June 16, 2012 at 3:07 PM, Kurt Harriger wrote: > > > On Saturday, June 16, 2012 1:28:21 PM UTC-6, Vinzent wrote: > > > I agree, an explicit type field makes dispatching easy. However this > > > data struc

Re: Doseq, map-style

2012-06-16 Thread Kurt Harriger
On Saturday, June 16, 2012 1:28:21 PM UTC-6, Vinzent wrote: > > I agree, an explicit type field makes dispatching easy. However this data >> structure returned by (http/get ... :as json) so if I want to add type >> information I need to walk the tree and rewrite it. Not necessarily a bad >>

Re: Doseq, map-style

2012-06-16 Thread Kurt Harriger
On Saturday, June 16, 2012 12:26:34 PM UTC-6, Sean Corfield wrote: > > On Sat, Jun 16, 2012 at 10:58 AM, Kurt Harriger > wrote: > > How does one turn off pre/post conditions in production? > > (binding [*assert* false] (call-my-code)) > > > I agree with Sean > > however and generally thin

Re: Doseq, map-style

2012-06-16 Thread Alex Baranosky
To test for violations of those assertions, possibly due to wonky data that only occurs in certain production-only circumstances. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that p

Re: Doseq, map-style

2012-06-16 Thread Vinzent
> > I actually think assertions should stay _on_ in production > Why? Could you please elaborate more on it? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new memb

Re: Doseq, map-style

2012-06-16 Thread Vinzent
> > I agree, an explicit type field makes dispatching easy. However this data > structure returned by (http/get ... :as json) so if I want to add type > information I need to walk the tree and rewrite it. Not necessarily a bad > idea, but in some cases the only thing I need is the eTag and so

Re: Doseq, map-style

2012-06-16 Thread Sean Corfield
On Sat, Jun 16, 2012 at 10:58 AM, Kurt Harriger wrote: > How does one turn off pre/post conditions in production? (binding [*assert* false] (call-my-code)) > I agree with Sean > however and generally think that assertions in production a bad thing. I didn't say that. I said the question was a p

Re: Doseq, map-style

2012-06-16 Thread Kurt Harriger
On Wednesday, June 13, 2012 2:52:15 AM UTC-6, Vinzent wrote: > > I do use pre-conditions where the test condition is simple, ie is this a >> string? does the map have a :field-type? however I get a lot of my input >> data from http requests as json which have similar structures but different >

Re: Doseq, map-style

2012-06-13 Thread Sean Corfield
On Wed, Jun 13, 2012 at 1:52 AM, Vinzent wrote: > Why do you care about computational expensiveness of pre and post > conditions? They'll be turned off in production anyway. I think that's a philosophical question :) > In clojure, structure of your map is a part of the contract. It's not an > im

Re: Doseq, map-style

2012-06-13 Thread Vinzent
> > I do use pre-conditions where the test condition is simple, ie is this a > string? does the map have a :field-type? however I get a lot of my input > data from http requests as json which have similar structures but different > semantics, so I often do not have preconditions where type is n

Re: Doseq, map-style

2012-06-12 Thread Kurt Harriger
On Tuesday, June 12, 2012 2:18:03 AM UTC-6, Christophe Grand wrote: > > Hi, > > To contrast our experiences of the language and the different approaches > to deal with some problems: > > On Sun, Jun 10, 2012 at 4:47 AM, Kurt Harriger wrote: > >> Many will say that side-effecting functions are m

Re: Doseq, map-style

2012-06-12 Thread Christophe Grand
Hi, To contrast our experiences of the language and the different approaches to deal with some problems: On Sun, Jun 10, 2012 at 4:47 AM, Kurt Harriger wrote: > Many will say that side-effecting functions are more difficult to test > then pure functions... However after writing about 4000 lines

Re: Doseq, map-style

2012-06-10 Thread David Jacobs
Von: *David Jacobs * > An: *clojure@googlegroups.com* > Gesendet: *Sa, 09 Jun 2012, 23:08:21 MESZ* > Betreff: *Re: Doseq, map-style > > Thanks, guys. > > I know there are easy ways to implement what I want. However, I'm more > curious as to why the language itself doesn

Re: Doseq, map-style

2012-06-10 Thread David Jacobs
This is good stuff. I've certainly felt the same way about FP at some points--for me, Clojure really illuminates why people thought OO was such a good thing 15 years ago. Let me know if you write that blog post. On Saturday, June 9, 2012 7:47:47 PM UTC-7, Kurt Harriger wrote: > > > You could a

Re: Doseq, map-style

2012-06-10 Thread Meikel Brandmeyer
liche Nachricht- Von: David Jacobs An: clojure@googlegroups.com Gesendet: Sa, 09 Jun 2012, 23:08:21 MESZ Betreff: Re: Doseq, map-style Thanks, guys. I know there are easy ways to implement what I want. However, I'm more curious as to why the language itself doesn't support this style

Re: Doseq, map-style

2012-06-10 Thread David Jacobs
I agree that it probably doesn't need to be a macro (your second suggestion was my first inclination). I didn't realize doseq took keyword options, that's good to know. On Saturday, June 9, 2012 at 7:51 PM, Walter Tetzner wrote: > > Is there a philosophical difference underlying the syntax

Re: Doseq, map-style

2012-06-09 Thread Walter Tetzner
> > Is there a philosophical difference underlying the syntax difference > (doseq [elem coll] (f coll)) and (each f coll)? > `doseq' is the side-effecty version of `'for', not map. It lets you do things like user> (doseq [x (range 100) :while (< x 20) :when (even? x)]

Re: Doseq, map-style

2012-06-09 Thread Kurt Harriger
You could also (dorun (map f coll)) It is actually interesting you brought this up as I was recently contrasting the OO principle "tell don't ask" with the functional way of doing things. In OO a void method taking a visitor is preferred over return values. One could perhaps say that (doru

Re: Doseq, map-style

2012-06-09 Thread David Jacobs
Thanks, guys. I know there are easy ways to implement what I want. However, I'm more curious as to why the language itself doesn't support this style of mapping side-effects. In other words, why does doseq not follow map's lead here. Is there a philosophical difference underlying the syntax di

Re: Doseq, map-style

2012-06-09 Thread Alex Baranosky
I'd just use doseq. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group,

Re: Doseq, map-style

2012-06-09 Thread Jim - FooBar();
I just saw this has been already answered! I apologise for the noise! Jim On 09/06/12 16:45, Jim - FooBar(); wrote: Why not make it yourself? Something like this perhaps? (defmacro doeach [f coll] `(doseq [x# ~coll] (~f x#))) Itis good if you name it "doeach" instead of each to imply side-ef

Re: Doseq, map-style

2012-06-09 Thread Jim - FooBar();
Why not make it yourself? Something like this perhaps? (defmacro doeach [f coll] `(doseq [x# ~coll] (~f x#))) Itis good if you name it "doeach" instead of each to imply side-effects (just like doseq)... Hope that helps... Jim On 08/06/12 04:32, David Jacobs wrote: I would love to have a ve

Re: Re: Doseq, map-style

2012-06-09 Thread Baishampayan Ghose
On Sat, Jun 9, 2012 at 6:13 PM, Meikel Brandmeyer wrote: > the doseq has the additional benefit of its ugliness which makes > side-effects stand out. ;) +1 Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- You received this message because you are subscribed to the Google Groups "Clo

AW: Re: Doseq, map-style

2012-06-09 Thread Meikel Brandmeyer
Hi, the doseq has the additional benefit of its ugliness which makes side-effects stand out. ;) Kind regards Meikel -Ursprüngliche Nachricht- Von: Sean Corfield An: clojure@googlegroups.com Gesendet: Sa, 09 Jun 2012, 04:50:53 MESZ Betreff: Re: Doseq, map-style On Thu, Jun 7, 2012 at

Re: Doseq, map-style

2012-06-09 Thread Baishampayan Ghose
> I would love to have a version of doseq that works like map (similar to > "each" in other dynamic languages). In other words, instead of (doseq [log > logs] (println log)), I would say something like (each println logs). > > Is there a built-in Clojure method that works like this? Since Clojure

Re: Doseq, map-style

2012-06-08 Thread Sean Corfield
On Thu, Jun 7, 2012 at 8:32 PM, David Jacobs wrote: > I would love to have a version of doseq that works like map (similar to > "each" in other dynamic languages). In other words, instead of (doseq [log > logs] (println log)), I would say something like (each println logs). Since that implies a s

Re: Doseq, map-style

2012-06-08 Thread Lars Nilsson
On Fri, Jun 8, 2012 at 9:54 AM, Allen Johnson wrote: > Combine map with dorun and you get the same effect: > > (dorun (map println logs)) > > http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/dorun > > Allen > > On Thu, Jun 7, 2012 at 11:32 PM, David Jacobs wrote: >> I would lo

Re: Doseq, map-style

2012-06-08 Thread Allen Johnson
Combine map with dorun and you get the same effect: (dorun (map println logs)) http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/dorun Allen On Thu, Jun 7, 2012 at 11:32 PM, David Jacobs wrote: > I would love to have a version of doseq that works like map (similar to > "each

Doseq, map-style

2012-06-08 Thread David Jacobs
I would love to have a version of doseq that works like map (similar to "each" in other dynamic languages). In other words, instead of (doseq [log logs] (println log)), I would say something like (each println logs). Is there a built-in Clojure method that works like this? -- You received this