Hi Konrad,
> I'm trying to write a newX function for a +Entity subclass and its
> behaving rather strangly. The code is as follows:
>
> (de newAdversary (Nm Tp Abs Spd Ht Def Arm)
> ...
> : (show '{2})
> {2} (+Adversary)
> armour 0
This looks all right (at least on the first glance).
> however the following is a problem
>
> : (select +Adversary)
> -> NIL
If 'select' can't find anything, it indicates that the new object isn't
properly indexed. Can you post the E/R definition of '+Adversary'?
> if I just create an empty +Adversary with new!, then select can see it
> just fine. According to the docs new! is just a short cut for what I'm
> doing in my function, so what am I missing?
This is correct.
Note, that this can be simplified a little:
1. Both 'new' and 'new!' accept key/value arguments. Instead of
(dbSync)
(with (new (db: +Cls) '(+Cls))
(=: a A)
(=: b B)
(=: c C)
...
(commit 'upd)
This )
you can write
(dbSync)
(new (db: +Cls) '(+Cls) 'a A 'b B 'c C ...)
(commit 'upd)
or even just
(new! '(+Cls) 'a A 'b B 'c C ...)
2. 'if' expressions in the form
(if Cond
(prog
(foo)
(bar) )
(mumble) )
could be written shorter as
(ifn Cond
(mumble)
(foo)
(bar) )
Cheers,
- Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe