Dynamically accessing property stored values

I’m trying to dynamically change properties,
for instance i’d like to write

a new object cloned from the man prototype with “George” as printed name and 72kg as weight

To decide what K is (O - value of kind K) with/and (V - L) as (P - value of kind L valued property):
	change the P of O to V;
	decide on O;

but i get the following error upon calling this phrase from another part of the source code

[i]Problem. In the sentence ‘change the P of O to V’ , I was expecting to read an object, but instead found some text that I couldn’t understand - ‘P of O’.
I was trying to match one of these phrases:

  1. change (p of o - object) to (v - property)
  2. change (p of o - text wrapper) to (v - indexed text)
  3. change (p of o - a stored value) to (v - value)
  4. change (p of o - object) to (v - enumerated value)
    This was what I found out:

P of O = something unrecognised
V = a temporary named value, holding a text
[/i]

I tried to use

To decide what K is (P - value of kind K valued property) property of (O - object):
(- {O}.{P} -).

I can “showme” it but I can’t change it as this phrase returns a value, not a reference.

Is there a way to dynamically process properties with i7 ?

There are I6 functions like WriteGProperty() and SetEitherOrProperty() that probably cover it. Compile any non-trivial project of yours and search the I6 source for how they’re used.

Then, I’d probably have to treat normal values and block values separately as well as create a phrase for handling text to indexed text casting (or is it the opposite ?).

But unfortunately i have to write:

pv = ConstantListPointers–>0; ConstantListPointers–>0 = BlkValueCreate(LIST_OF_TY,pv,KD5_list_of_numbers);

in the InitialHeapAllocation routine if I want to write

! [5: change the test_list_of_numbers of x to { 3 , 4 }]
BlkValueCopy(GProperty(OBJECT_TY, t_0,p33_test_list_of_numbers), ConstantListPointers–>0);

A quick look at the “To change…” phrase

To change (S - storage) to (w - value) (deprecated)
(assignment operation) (documented at ph_change_dep): (- {-assignment}; -).

shows everything is handled by the assignment invocation label. Also I don’t see how i could build a “storage” from a property and an object. I don’t even see this type’s description in Load-Core.i6t.
I only see a wall. A big high wall

::nods solemnly::

I know nothing of the Dynamic extensions, but the 6Exx builds can distinguish between “word values” and “pointer values” which you’d use in the declaration of the To phrases, not unlike in your original post. (Pointer value == block value, if that isn’t already clear.) So I’m pretty sure what you’re after is do-able, if a bit obscure to figure out.

Might make a nice little extension when you’re done, though. If for no other reason than so others needn’t figure it out later. Plus, reading tricky extensions is a good way for anyone to learn the finer points of I7.

here 's (one of) the extension I’m working on:

[spoiler][code]
Easier Dynamic Objects by Phonatacid begins here.

Include Dynamic Objects by Jesse McGrew.

Use thriftiness translates as (- Constant EDO_THRIFTINESS; -).

Part 1 - New objects

Chapter 1 - Pools for alive and dead objects

An abstract pool is a kind of container.

The object_alive_pool is an abstract pool.
The object_dead_pool is an abstract pool.

Chapter 2 - The ‘New K’ phrase

[will trigger a series errors at compilation time if it is applied to a non-object value]
To decide what K is a new (name of kind of value K):
let D be the default value of K;
if the thriftiness option is active:
if there is a K contained by the object_dead_pool:
let RV be a random K contained by the object_dead_pool;
follow the Object Resuscitation rulebook for RV;
[copy the properties of the default value of K to RV]
decide on RV;
else:
let RV be a new object cloned from D;
move RV to the object_alive_pool;
decide on RV;
else:
decide on a new object cloned from D;

Section 1 - The Object Resuscitation rulebook

[this rulebook can be used for resetting the object’s properties to their default values.]
The Object Resuscitation rules is a thing based rulebook.

First Object Resuscitation for a thing (called O)
(this is the default resuscitation rule):
move O to the object_alive_pool;

Chapter 3 - Destroying Objects

To destroy (O - object):
move V to the object_dead_pool;

Part 2 - Properties management

Chapter 1- Creating objects along with their properties

[For instance,
let x be a new man with “george” as printed name and 28kg as weight;

Unfortunately it won’t compile but this willl
let x be (a new man with "george as printed name) and 28kg as weight;]

To decide what K is (O - value of kind K) with/and (V - L) as (P - value of kind L valued property):
change the P property of O to V;
decide on O;

To change the (P - word value of kind K valued property) property of (O - object) to (V - K):
(- WriteGProperty(OBJECT_TY, {O}, {P}, {V}); -).

To change the (P - pointer value of kind K valued property) property of (O - object) to (V - K):
(- BlkValueCopy(GProperty(OBJECT_TY, {O}, {P}), {V}); -).

To change (P - indexed text valued property) property of (O - object) to (V - text):
(- BlkValueCast(GProperty(OBJECT_TY, {O}, {P}), INDEXED_TEXT_TY, TEXT_TY, {V}); -).

Chapter 2 - Copying properties from object to object

[To copy the properties of (SRC - value of kind K) in/into/to (DST - K):
(- EDO_CopyProperties({SRC}, {DST}); -).

Include(-
[ EDO_CopyProperties src dst;
];-).
]

Easier Dynamic Objects ends here.
[/code][/spoiler]

How it works :
Based on a suggestion I received from Jesse, this extension now allows objects to be (pseudo) destroyed :
-when an object is destroyed, it is pooled to an off-stage container
-when an object of kind K is created, the system looks for a (unused) K in the aforementioned container instead of blindly creating a new object.

[u]A few problems[/u]
-I haven’t been able to create a routine that copies the properties from one K to another (so that the properties of a K are reinitialized to the properties of the default value when resuscitating an object. As a workaround, you can write an Object Resuscitation rule for K;
-You can now set several properties with one line only:
let x be a new man with “George” as printed name;
but
let x be a new man;
let x be x with “George” as printed name;

is also possible.
you can change multiple properties at once:
let x be a new man with “George” as printed name and 92kg as weight;
If you want to change/set more than 2 properties, you’ll have to help the compiler with a few parenthesis
let x be (a new man with "George as printed name and 92kg as weight) and 5 as strength;
I thought I could overcome this problem by using line breaks, but unfortunately, line break aren’t considered as parenthesis by the compiler. Maybe that would make for a good suggestion ?

edit: oh and sorry for the previous jazz. you were right about the GProperty routines.

(Since PAX starts in a few hours, it’ll be close to a week before I can begin exploring this. Just a heads-up, especially if someone else can chime in.)