Re: Has deftype changed?

2010-04-18 Thread Praki Prakash
Thanks Andrew.

I did catch 'this' argument requirement sometime back but the 'new' bit
escaped me.

Praki

On Sat, Apr 17, 2010 at 6:16 PM, Andrew Stein steinl...@gmail.com wrote:


 (deftype Bar [a b c d e])
 (def b (new Bar 1 2 3 4 5))

 There are a few other syntax changes too, defrecord replaces extending
 IPersistenMap, and you need to include 'this' in protocol fun
 implementations ...


 http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/deftype

 http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/defrecord

 On Apr 17, 4:37 pm, Praki praki.prak...@gmail.com wrote:
  I am seeing compilation errors in my code with deftype. I just updated
  my project dependencies and probably pulled in the latest clojure
  package. Anyway, the following code from wiki doesn't work anymore.
  Pointers to any late breaking changes much appreciated!
 
  TIA
 
  (deftype Bar [a b c d e])
  (def b (Bar 1 2 3 4 5))
 
  Expecting var, but Bar is mapped to class package.Bar
[Thrown class java.lang.Exception]
 
  Restarts:
   0: [ABORT] Return to SLIME's top level.
 
  Backtrace:
0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
4: clojure.lang.Compiler.analyze(Compiler.java:5140)
5: clojure.lang.Compiler.access$100(Compiler.java:35)
6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
8: clojure.lang.Compiler.analyze(Compiler.java:5140)
9: clojure.lang.Compiler.analyze(Compiler.java:5101)
   10: clojure.lang.Compiler.eval(Compiler.java:5377)
   11:
 
  --
  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, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group athttp://
 groups.google.com/group/clojure?hl=en

 --
 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, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
http://www.google.com/profiles/praki.prakash

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Has deftype changed?

2010-04-18 Thread Rob Lachlan
For deeftype, has the syntax for field accessors changed too?

I can't get it to work:

user (deftype someType [b f])
user.someType
user (def y (new someType 2 3))
#'user/y
user (:b y)
nil
user (:f y)
nil

defrecord works as expected, though.


On Apr 17, 6:16 pm, Andrew Stein steinl...@gmail.com wrote:
 (deftype Bar [a b c d e])
 (def b (new Bar 1 2 3 4 5))

 There are a few other syntax changes too, defrecord replaces extending
 IPersistenMap, and you need to include 'this' in protocol fun
 implementations ...

 http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co...

 On Apr 17, 4:37 pm, Praki praki.prak...@gmail.com wrote:





  I am seeing compilation errors in my code with deftype. I just updated
  my project dependencies and probably pulled in the latest clojure
  package. Anyway, the following code from wiki doesn't work anymore.
  Pointers to any late breaking changes much appreciated!

  TIA

  (deftype Bar [a b c d e])
  (def b (Bar 1 2 3 4 5))

  Expecting var, but Bar is mapped to class package.Bar
    [Thrown class java.lang.Exception]

  Restarts:
   0: [ABORT] Return to SLIME's top level.

  Backtrace:
    0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
    1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
    2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
    3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
    4: clojure.lang.Compiler.analyze(Compiler.java:5140)
    5: clojure.lang.Compiler.access$100(Compiler.java:35)
    6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
    7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
    8: clojure.lang.Compiler.analyze(Compiler.java:5140)
    9: clojure.lang.Compiler.analyze(Compiler.java:5101)
   10: clojure.lang.Compiler.eval(Compiler.java:5377)
   11:

  --
  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, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group 
  athttp://groups.google.com/group/clojure?hl=en

 --
 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, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/clojure?hl=en

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Has deftype changed?

2010-04-18 Thread David Nolen
On Sun, Apr 18, 2010 at 1:49 PM, Rob Lachlan robertlach...@gmail.comwrote:

 For deeftype, has the syntax for field accessors changed too?

 I can't get it to work:

 user (deftype someType [b f])
 user.someType
 user (def y (new someType 2 3))
 #'user/y
 user (:b y)
 nil
 user (:f y)
 nil

 defrecord works as expected, though.


deftype now generates a Java class.

(.b y)
(.f y)

should work

David

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Has deftype changed?

2010-04-18 Thread ataggart
My sense from the changes is that defrecord is the map-like one,
whereas deftype is the lower-level construct used to implement stuff
like clojure collections.  I imagine users will use defrecord more
often than deftype.


On Apr 18, 10:49 am, Rob Lachlan robertlach...@gmail.com wrote:
 For deeftype, has the syntax for field accessors changed too?

 I can't get it to work:

 user (deftype someType [b f])
 user.someType
 user (def y (new someType 2 3))
 #'user/y
 user (:b y)
 nil
 user (:f y)
 nil

 defrecord works as expected, though.

 On Apr 17, 6:16 pm, Andrew Stein steinl...@gmail.com wrote:





  (deftype Bar [a b c d e])
  (def b (new Bar 1 2 3 4 5))

  There are a few other syntax changes too, defrecord replaces extending
  IPersistenMap, and you need to include 'this' in protocol fun
  implementations ...

 http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co..

  On Apr 17, 4:37 pm, Praki praki.prak...@gmail.com wrote:

   I am seeing compilation errors in my code with deftype. I just updated
   my project dependencies and probably pulled in the latest clojure
   package. Anyway, the following code from wiki doesn't work anymore.
   Pointers to any late breaking changes much appreciated!

   TIA

   (deftype Bar [a b c d e])
   (def b (Bar 1 2 3 4 5))

   Expecting var, but Bar is mapped to class package.Bar
     [Thrown class java.lang.Exception]

   Restarts:
    0: [ABORT] Return to SLIME's top level.

   Backtrace:
     0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
     1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
     2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
     3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
     4: clojure.lang.Compiler.analyze(Compiler.java:5140)
     5: clojure.lang.Compiler.access$100(Compiler.java:35)
     6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
     7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
     8: clojure.lang.Compiler.analyze(Compiler.java:5140)
     9: clojure.lang.Compiler.analyze(Compiler.java:5101)
    10: clojure.lang.Compiler.eval(Compiler.java:5377)
    11:

   --
   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, send email to
   clojure+unsubscr...@googlegroups.com
   For more options, visit this group 
   athttp://groups.google.com/group/clojure?hl=en

  --
  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, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group 
  athttp://groups.google.com/group/clojure?hl=en

 --
 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, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/clojure?hl=en

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Has deftype changed?

2010-04-18 Thread Praki Prakash
That was my interpretation as well. I now have defrecord instead of deftype
everywhere. It looks like deftype was refactored into deftype and defrecord.
deftype implements none of the usual interfaces (IPersistentMap) whereas
defrecord does.

Praki

On Sun, Apr 18, 2010 at 11:33 AM, ataggart alex.tagg...@gmail.com wrote:

 My sense from the changes is that defrecord is the map-like one,
 whereas deftype is the lower-level construct used to implement stuff
 like clojure collections.  I imagine users will use defrecord more
 often than deftype.


 On Apr 18, 10:49 am, Rob Lachlan robertlach...@gmail.com wrote:
  For deeftype, has the syntax for field accessors changed too?
 
  I can't get it to work:
 
  user (deftype someType [b f])
  user.someType
  user (def y (new someType 2 3))
  #'user/y
  user (:b y)
  nil
  user (:f y)
  nil
 
  defrecord works as expected, though.
 
  On Apr 17, 6:16 pm, Andrew Stein steinl...@gmail.com wrote:
 
 
 
 
 
   (deftype Bar [a b c d e])
   (def b (new Bar 1 2 3 4 5))
 
   There are a few other syntax changes too, defrecord replaces extending
   IPersistenMap, and you need to include 'this' in protocol fun
   implementations ...
 
  
 http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co
 ..
 
   On Apr 17, 4:37 pm, Praki praki.prak...@gmail.com wrote:
 
I am seeing compilation errors in my code with deftype. I just
 updated
my project dependencies and probably pulled in the latest clojure
package. Anyway, the following code from wiki doesn't work anymore.
Pointers to any late breaking changes much appreciated!
 
TIA
 
(deftype Bar [a b c d e])
(def b (Bar 1 2 3 4 5))
 
Expecting var, but Bar is mapped to class package.Bar
  [Thrown class java.lang.Exception]
 
Restarts:
 0: [ABORT] Return to SLIME's top level.
 
Backtrace:
  0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
  1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
  2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
  3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
  4: clojure.lang.Compiler.analyze(Compiler.java:5140)
  5: clojure.lang.Compiler.access$100(Compiler.java:35)
  6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
  7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
  8: clojure.lang.Compiler.analyze(Compiler.java:5140)
  9: clojure.lang.Compiler.analyze(Compiler.java:5101)
 10: clojure.lang.Compiler.eval(Compiler.java:5377)
 11:
 
--
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, send email to
clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
For more options, visit this group athttp://
 groups.google.com/group/clojure?hl=en
 
   --
   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, send email to
   clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
   For more options, visit this group athttp://
 groups.google.com/group/clojure?hl=en
 
  --
  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, send email to
  clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
  For more options, visit this group athttp://
 groups.google.com/group/clojure?hl=en

 --
 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, send email to
 clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en




-- 
http://www.google.com/profiles/praki.prakash

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Has deftype changed?

2010-04-17 Thread Praki
I am seeing compilation errors in my code with deftype. I just updated
my project dependencies and probably pulled in the latest clojure
package. Anyway, the following code from wiki doesn't work anymore.
Pointers to any late breaking changes much appreciated!

TIA

(deftype Bar [a b c d e])
(def b (Bar 1 2 3 4 5))

Expecting var, but Bar is mapped to class package.Bar
  [Thrown class java.lang.Exception]

Restarts:
 0: [ABORT] Return to SLIME's top level.

Backtrace:
  0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
  1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
  2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
  3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
  4: clojure.lang.Compiler.analyze(Compiler.java:5140)
  5: clojure.lang.Compiler.access$100(Compiler.java:35)
  6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
  7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
  8: clojure.lang.Compiler.analyze(Compiler.java:5140)
  9: clojure.lang.Compiler.analyze(Compiler.java:5101)
 10: clojure.lang.Compiler.eval(Compiler.java:5377)
 11:

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Has deftype changed?

2010-04-17 Thread Andrew Stein

(deftype Bar [a b c d e])
(def b (new Bar 1 2 3 4 5))

There are a few other syntax changes too, defrecord replaces extending
IPersistenMap, and you need to include 'this' in protocol fun
implementations ...

http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/deftype
http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/defrecord

On Apr 17, 4:37 pm, Praki praki.prak...@gmail.com wrote:
 I am seeing compilation errors in my code with deftype. I just updated
 my project dependencies and probably pulled in the latest clojure
 package. Anyway, the following code from wiki doesn't work anymore.
 Pointers to any late breaking changes much appreciated!

 TIA

 (deftype Bar [a b c d e])
 (def b (Bar 1 2 3 4 5))

 Expecting var, but Bar is mapped to class package.Bar
   [Thrown class java.lang.Exception]

 Restarts:
  0: [ABORT] Return to SLIME's top level.

 Backtrace:
   0: clojure.lang.Compiler.lookupVar(Compiler.java:5677)
   1: clojure.lang.Compiler.isMacro(Compiler.java:5178)
   2: clojure.lang.Compiler.macroexpand1(Compiler.java:5233)
   3: clojure.lang.Compiler.analyzeSeq(Compiler.java:5305)
   4: clojure.lang.Compiler.analyze(Compiler.java:5140)
   5: clojure.lang.Compiler.access$100(Compiler.java:35)
   6: clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:417)
   7: clojure.lang.Compiler.analyzeSeq(Compiler.java:5319)
   8: clojure.lang.Compiler.analyze(Compiler.java:5140)
   9: clojure.lang.Compiler.analyze(Compiler.java:5101)
  10: clojure.lang.Compiler.eval(Compiler.java:5377)
  11:

 --
 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, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/clojure?hl=en

-- 
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, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en