[fxruby-users] FXVec* default constructors

Jeroen van der Zijp jeroen at fox-toolkit.org
Mon Jan 26 10:41:47 EST 2009

On Monday 26 January 2009, David MacMahon wrote:
> I just noticed that the default constructors for FXVec* do not  
> initialize their elements.  This also affects anything that uses  
> FXVec* default constructors under the covers such as the FXExtent*  
> default constructors.

This is in the interest of speed; one often makes [very large] arrays
of these things, and initializing them would be time-consuming.

> It would be nice if the docs were explicit on this "point". :-)

I'll update the doc-comments.

> Perhaps this is the expected behavior in C++ given the various ways  
> that the C++ default constructor can be invoked, but in Ruby I was  
> expecting the no-argument constructor to initialize the instance to  
> [0.0, 0.0]...

There is no rule that says it need to be initialized or not in C++; it all
depends on what the developer wants.  In this case, they're intended to
behave very much like the regular "plain old data" types, which are also
only initialized if you explicitly do so.  Speed is the reason why this
was done.

		- Jeroen

More information about the fxruby-users mailing list