Jussi,

It's not an illegal assignment, nor is it a type mismatch. It is not
setting a different object reference to the same variable, it is
removing the object reference from the variable.

"a" is a pointer to an instance of a newly instantiated Class1 object.
Setting "a" to null is perfectly valid. "a" then no longer points to an
instance.  Therefore the object reference count is decremented (in this
case to 0, so the object memory can be freed).

It's all there in the help under the Gambas Object Management topic.

hth
Bruce


On Fri, 2011-08-26 at 14:56 +0300, Jussi Lahtinen wrote:
> I didn't say compiler should stop, interpreter should stop!
> 
> It shouldn't be legal for same reason as these:
> Dim a As Integer = "string"
> Dim a As Integer = Null
> 
> It's type mismatch. Null is not same as zero.
> If you want to be able to give two different object references to same
> variable, use type object or variant.
> 
> Also this is change in behaviour, since earlier you had to declare variable
> for multiple different objects as object.
> Dim a As Object
> Only then variable 'a' was able to be whatever; Class1, TextBox or Null.
> 
> Sometimes I use object as parameter type so that I can use null to signify
> missing object,
> but then my code is made to handle nulls. So the biggest problem is
> debugging.
> 
> Is there some standard for how this should be?
> 
> Jussi
> 
> 
> 
> On Fri, Aug 26, 2011 at 09:20, Caveat <gam...@caveat.demon.co.uk> wrote:
> 
> > Why shouldn't it be legal?  As it stands, it's not good code and it's
> > certainly not very useful but why should the compiler stop you setting
> > something to null?  What if there's a line of code between, should it
> > then be legal?
> >
> > regards,
> > Caveat
> >
> > On Fri, 2011-08-26 at 02:35 +0300, Jussi Lahtinen wrote:
> > > I think this shouldn't be legal:
> > >
> > > Dim a As New Class1
> > > a = Null
> > >
> > > But there is no error message.
> > >
> > > Gambas 3 rev 4039 @ Ubuntu 11.04 64bit
> > >
> > >
> > > Jussi
> > >
> > ------------------------------------------------------------------------------
> > > EMC VNX: the world's simplest storage, starting under $10K
> > > The only unified storage solution that offers unified management
> > > Up to 160% more powerful than alternatives and 25% more efficient.
> > > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> > > _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> >
> >
> >
> > ------------------------------------------------------------------------------
> > EMC VNX: the world's simplest storage, starting under $10K
> > The only unified storage solution that offers unified management
> > Up to 160% more powerful than alternatives and 25% more efficient.
> > Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------------------------
> EMC VNX: the world's simplest storage, starting under $10K
> The only unified storage solution that offers unified management 
> Up to 160% more powerful than alternatives and 25% more efficient. 
> Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user



------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management 
Up to 160% more powerful than alternatives and 25% more efficient. 
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to