From: Jonathan Allen <[email protected]> - 3 Mar 1999
I am using mk4tcl on Windows 98 (I know, I know), and am seeing some unexpected behavior using mk::set. I am using mk::set to add a new property to a row. The documention implies that the view definition will be updated, and it is until I close the datafile and re-open it. Once I do that, the view is missing my new property. Doing a commit before closing doesn't make a difference. If I add the new property using the mk::view layout command, it works properly.
Reply:
Hm, this is intentional, but the way you describe it, I can understand the confusion this causes.
The way restructuring works, is that it requires you to define (and re-define) the structure before use. I later found ways to extend this, but there there are some unfortunate interactions which complicate this (due to "attached" vs. "unattached" views - you don't want to know...).
So I'm gradually returning to the point where Metakit will only store the structure it has been told.
The reason one *can* add any property to any view, is that this offers a way to keep temporary data in memory. There are some very good uses for the ability to have rows on disk, and to be able to keep some cached data while actively in use (derived/calculated results, for example).
I now see how "mk::view layout" is confusing by listing those temporary properties, without a hint that they are temporary.
I am looking at ways to define a cleaner distinction though, and hope to simplify once "attached vs. unattached" gets dropped (later this year).
In your case, the thing to do is to make all changes to the structure explicit: call "mk::view layout" *before* storing new properties. You can also do things like this to avoid tracking the structure yourself:
set layout [mk::view layout db.user] lappend layout NewField mk::view layout db.user $layout
Thanks for bringing this up, I'll keep it in mind when redesigning it.
-- JC