Arc Forumnew | comments | leaders | submitlogin
2 points by conanite 5359 days ago | link | parent

I share your guess that 'obj is a contraction of "object". I don't think it means exactly what your example suggests. Continuing your example, if you write

  (= conanite vampire)
, the symbols 'vampire, 'conanite and 'Dracula all refer to the same object instance, so it's probably not what you want. In other words, you can turn conanite's hair blue like this:

  (= Dracula!hair 'blue) ; *not tested*
I don't know if it's the glue, but I think 'deftem ("define template") and 'inst ("instantiate template") do what you describe here.

  (deftem vampire name nil fangs 2 hair 'black requires 'blood) ; sorry, my vampire is defined a little differently
'deftem sorta kinda creates a "class" - but only with data slots, no behaviour.[1] Now, if you want to call up some vampires,

  (= Dracula (inst 'vampire 'name "Dracula"))
  (= conanite (inst 'vampire 'hair 'gray))
inst is pretty similar to obj, except internally it relies on a set of preconfigured "templates" which provide the set of keys (and their default values) for the thing you are going to build. It's used in blog.arc to define blog posts, as well as news.arc to define news items, and user accounts.

[1] at least, not by design, but there's nothing to stop you from assigning a function as the default value of any slot; except then it couldn't really be written to disk ...



2 points by thaddeus 5359 days ago | link

Ah... you're correct. I was thinking of the inst behaviour.

Too bad the following doesn't work:

   arc> (= vampire (obj teeth "fangs" hair "black" food "blood"))
   #hash((hair . "black") (food . "blood") (teeth . "fangs"))
   arc> (= Dracula (inst 'vampire))
   #hash()
Thanks for the correction... (haven't worked on arc for a few weeks :) T.

-----