Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
October 14, 2002 Where were gettor/settors documented? | ||||
---|---|---|---|---|
| ||||
For some reason, I can't find them in the docs. The online search isn't finding it, either. Also, are they implemented yet? Can I use gettors & settors to control access to a structure member without using assignment syntax? For instance, if I have this expression: struct Foo {...}; Foo foo; int x = foo.bar.baz.xyz; // throws an exception // "foo.valid.bar is false" foo.bar.baz.xyz = 3; // automatically sets foo.valid.bar = true int y = foo.bar.baz.xyz; // now this is legal I'd like to be able to define a gettors and settors that do this. The thing here is that I don't want to define gettors & settors on the "xyz" member, but on the "bar" member of the "Foo" struct. I want it such that if somebody does a "read-type" operation on any member of "bar", the gettor for "bar" is called, and if they do a "write-type" operation on any member of "bar", then the settor for "bar" is set. It's like a dynamic access-control to members. I don't expect that this is possible with current gettors & settors. Am I right? Does anybody else see any utility here? |
October 14, 2002 Re: Where were gettor/settors documented? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Lewis | The documentation for gettor/settors is in class.html, which is included in the download, under the topic "Fields". Gettor/settors are listed as not being implemented in the Bugs section of alpha.html.
It would be great to see them implemented.
Paul
Russell Lewis wrote:
> For some reason, I can't find them in the docs. The online search isn't finding it, either.
>
> Also, are they implemented yet?
>
> Can I use gettors & settors to control access to a structure member without using assignment syntax? For instance, if I have this expression:
>
> struct Foo {...};
>
> Foo foo;
> int x = foo.bar.baz.xyz; // throws an exception
> // "foo.valid.bar is false"
> foo.bar.baz.xyz = 3; // automatically sets foo.valid.bar = true
> int y = foo.bar.baz.xyz; // now this is legal
>
> I'd like to be able to define a gettors and settors that do this. The thing here is that I don't want to define gettors & settors on the "xyz" member, but on the "bar" member of the "Foo" struct. I want it such that if somebody does a "read-type" operation on any member of "bar", the gettor for "bar" is called, and if they do a "write-type" operation on any member of "bar", then the settor for "bar" is set.
>
> It's like a dynamic access-control to members.
>
> I don't expect that this is possible with current gettors & settors. Am I right? Does anybody else see any utility here?
>
|
October 14, 2002 gettor/settors instead of volatile? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Runde | In article <3DAADDC0.8090001@mcleodusa.net>, Paul Runde says... > >The documentation for gettor/settors is in class.html, which is included in the download, under the topic "Fields". Gettor/settors are listed as not being implemented in the Bugs section of alpha.html. > >It would be great to see them implemented. > >Paul I think properties would be great, I think they might take care of the "volatile" issue too. One of the big problems with not having volatile is that you need peeks and pokes all over the place. If you had some kind of property representing that physical address, you could just have a settor containing the poke, and a gettor containing a peek, and access the location just like any other variable. Just a thought. Jon |
October 14, 2002 Re: gettor/settors instead of volatile? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Andrew | Jonathan Andrew wrote:
> In article <3DAADDC0.8090001@mcleodusa.net>, Paul Runde says...
>
>>The documentation for gettor/settors is in class.html, which is included in the download, under the topic "Fields". Gettor/settors are listed as not being implemented in the Bugs section of alpha.html.
>>
>>It would be great to see them implemented.
>>
>>Paul
>
>
> I think properties would be great, I think they might take care of the
> "volatile" issue too. One of the big problems with not having volatile
> is that you need peeks and pokes all over the place. If you had some
> kind of property representing that physical address, you could just
> have a settor containing the poke, and a gettor containing a peek,
> and access the location just like any other variable.
>
> Just a thought.
> Jon
Yes, being able to add properties would be very nice. However, I was looking for something a little easier (?) to implement. I was assuming that there was an underlying foo._bar object which held the actual data, and the foo.bar gettor & settor were just frontends to that.
|
October 15, 2002 Re: gettor/settors instead of volatile? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russell Lewis |
>
> Yes, being able to add properties would be very nice. However, I was looking for something a little easier (?) to implement. I was assuming that there was an underlying foo._bar object which held the actual data, and the foo.bar gettor & settor were just frontends to that.
>
Oh absolutely, that would be the most common usage, I was merely
pointing out a possible solution to the volatile problem.
Jon
|
Copyright © 1999-2021 by the D Language Foundation