From: Hal Fulton Date: 2012-04-06T00:18:00+09:00 Subject: Re: Call for comments - Structure --bcaec517a72282ae5604bcf00bbd Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable 2012/4/5 Robert Klemme > On Thu, Apr 5, 2012 at 4:33 PM, Bartosz Dziewo=F1ski > wrote:> Struct just does not have instance variables, which is surprising= , > > I know - that's the whole point why "#instance_variables returns an > empty list". But the question was, whether this is the reason Hal > calls them "unreal" - and whether it matters. Both can probably only > be answered by him since he coined the phrase... > > > if you assume that "Point =3D Struct :x, :y" is a shorthand for "class > > Point; attr_accessor :x, :y; def initialize x, y; @x, @y =3D x, y; end; > > end". > > Well, obviously it is not a shorthand for the code you show. :-) > Still it doesn't explain why Hal calls them "unreal". We are still > only guessing as to what intentions his might have been. > Bartosz has understood my point. I don't mind that instance_variables returns an empty list, but I have been annoyed at the difficulty or impossibility of reopening the class to add useful methods that manipulate the instance data. As a side issue, I wanted more flexible access to the members and more freedom in creating classes and objects. (In general, I would rather say obj.this.that than to say obj['this']['that'], and I'd like to freely convert to and from hashes.) But of course, it is perfectly valid for anyone to say they don't like the idea. It would not be the first time I tried to solve a problem that many or most others did not perceive at all. Hal --bcaec517a72282ae5604bcf00bbd Content-Type: text/html; charset=ISO-8859-2 Content-Transfer-Encoding: quoted-printable 2012/4/5 Robert Klemme <shortcutter@googlemail.com>
On Thu, Apr 5, 2012 at 4:33 PM, Bartosz Dziewo=F1ski <= matma.rex@gmail.com> wrote:&g= t; Struct just does not have instance variables, which is surprising,

I know - that's the whole point why "#instance_variables ret= urns an
empty list". =A0But the question was, whether this is the reason Hal calls them "unreal" - and whether it matters. =A0Both can probabl= y only
be answered by him since he coined the phrase...

> if you assume that "Point =3D Struct :x, :y" is a shorthand = for "class
> Point; attr_accessor :x, :y; def initialize x, y; @x, @y =3D x, y; end= ;
> end".

Well, obviously it is not a shorthand for the code you show. :-)
Still it doesn't explain why Hal calls them "unreal". =A0We a= re still
only guessing as to what intentions his might have been.

Bartosz has understood my point. I don't mind that instance_vari= ables
returns an empty list, but I have been annoyed at the difficulty o= r impossibility
of reopening the class to add useful methods that manipulate the
instan= ce data.

As a side issue, I wanted more flexible access to the membe= rs and more
freedom in creating classes and objects. (In general, I woul= d rather say
obj.this.that than to say obj['this']['that'], and I'd = like to freely convert to
and from hashes.)

But of course, it is = perfectly valid for anyone to say they don't like the idea.
It would= not be the first time I tried to solve a problem that many or most
others did not perceive at all.

Hal

=A0
--bcaec517a72282ae5604bcf00bbd--