cpli has quit [Write error: Connection reset by peer]
casaca has quit [Write error: Connection reset by peer]
payphone has quit [Read error: Connection reset by peer]
casaca has joined #picolisp
cpli has joined #picolisp
payphone has joined #picolisp
seninha has joined #picolisp
abu[7] has left #picolisp [#picolisp]
abu[7] has joined #picolisp
abu[7] has joined #picolisp
beneroth has joined #picolisp
chexum has quit [Remote host closed the connection]
chexum has joined #picolisp
pablo_escoberg has joined #picolisp
<pablo_escoberg>
I'm having some trouble understanding how "new" works. Why does this happen:
<pablo_escoberg>
entities! This
<pablo_escoberg>
-> +User
<pablo_escoberg>
entities! (type (new (This)))
<pablo_escoberg>
-> NIL
<pablo_escoberg>
entities! (type (new '(+User)))
<pablo_escoberg>
-> (+User)
<pablo_escoberg>
and, of course, how do I create an object of a class from within a method of that class?
<abu[7]>
(new (This)) is fatal!
<abu[7]>
'This' is not a function
<abu[7]>
(new '(+User)) is good
<abu[7]>
But if +User is expected to be an external symbol, you need e.g. (new T '(+User))
<abu[7]>
or (new! '(+User)) which takes care of the file etc.
<pablo_escoberg>
Hmmmm... so how do I get to '(+User) from `This` which is `+User`?
<abu[7]>
(new <num> (type This))
<pablo_escoberg>
ah!
<pablo_escoberg>
TY
<abu[7]>
you need to find the db file though
<abu[7]>
(new 3 (type This))
<pablo_escoberg>
well, I'm just using one file for this, so I think (new T (type this)) right?
<pablo_escoberg>
or just (new 1 (type this)) ?
<abu[7]>
yeah, perfect
<abu[7]>
Just for the records, getting the file is a bit tricky
<pablo_escoberg>
so 1 is better than T here?
<abu[7]>
(new (db: +User) '(+User))
<abu[7]>
will be
<pablo_escoberg>
awesome
<abu[7]>
(new (meta (type This) 'Dbf 1) (type This) ...
<abu[7]>
So 'new!' is a lot easier ;)
<pablo_escoberg>
yeah, but I want to validate before saving
<abu[7]>
Better validate before *calling*
<pablo_escoberg>
hmmmm.... I'll look into that. Maybe use the class methods for validation rather than object methods.
<abu[7]>
Good idea
<pablo_escoberg>
Right now, I'm creating self-validating objects
<pablo_escoberg>
but that may not be the right way to go.
<beneroth>
hey pablo_escoberg
<abu[7]>
Not sure what is the best way. Just play around
<pablo_escoberg>
yup, will do.
<abu[7]>
Hi beneroth!
<pablo_escoberg>
hey beneroth
<beneroth>
smells like over-complicating things, but try it out :)
<pablo_escoberg>
could well be. There's something elegant about it, but using class methods may be more practical.
<beneroth>
what's practical about class methods? the grouping in thematic classes? or that you can overwrite the behavior with subclasses or prefix classes?
<beneroth>
I mean: what do you find practical about class methods?
<abu[7]>
There is one drawback if you call 'new' without committing and then 'rollback': There is one symbol created in the DB which will re-used only with 'dbck'
<pablo_escoberg>
well, in this case it's about class methods vs object methods. I realize the two are almost equivalent, but the devil is in the details. Right now, I am building self-validating objects and running into issues. I may be able to overcome them without making a mess, but if I end up making a mess, I'll fall back to class methods.
<pablo_escoberg>
Hmmmm.... I'll play around with creating the validating object as an internal symbol, and if valid, externing it.
<beneroth>
that sounds better, separating the different phases
<abu[7]>
yep
<pablo_escoberg>
great. Guess I'm on the right track.
pablo_escoberg has quit [Ping timeout: 245 seconds]
msavoritias has quit [Remote host closed the connection]