• Advertisement
Sign in to follow this  

asEP_ALLOW_IMPLICIT_HANDLE_TYPES and OMG!

This topic is 1909 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi smile.png

I was very tormented native system of work with references! I always use the links to be mistaken! But sometimes mistaken.


Always difficult to know what can make this code:


http://www.everfall....hp?8x2ooxr0acic


class Imp
{
Imp() { val = 9; }
string GetStr() { return "" + val; }
int val;
}
void startGame( string &param )
{
Imp im = Imp();
Imp @im2 = Imp();

im2.val = 99;

im2 = im; // Why need copy, why why why ? im2 its Reference!sad.png

im.val = 0;

output( "im: " + im.GetStr() );
output( "im2: " + im2.GetStr() );
}[/quote]



I often make a mistake forgetting to write "@" im2 = im


I found this thread: http://www.gamedev.n...etreturntypeid/

and i look in to - https://angelscript....licithandle.cpp And i say: OMG!!!! O! M! G!!!!ohmy.png

Why did I not know about this before? It would have saved me a lot of nerve! I am angry at myself!

But! How to register c++ class ?



r=en->RegisterObjectType( "Scene", 0, asOBJ_REF | asOBJ_NOCOUNT ); assert( r >= 0 );



try this:


r=en->RegisterObjectType( "class@ Scene", 0, asOBJ_REF | asOBJ_NOCOUNT ); assert( r >= 0 );

r=en->RegisterObjectType( "@Scene", 0, asOBJ_REF | asOBJ_NOCOUNT ); assert( r >= 0 );
r=en->RegisterObjectType( "Scene@", 0, asOBJ_REF | asOBJ_NOCOUNT ); assert( r >= 0 );

i can fail, fail, fail. Edited by FDsagizi

Share this post


Link to post
Share on other sites
Advertisement
The implicit handle feature is just experimental at the moment. Unfortunately it only works for script declared classes, and not registered classes.

Share this post


Link to post
Share on other sites
For version 3.0 I'm considering going 100% implicit handles and remove the @ symbol completely from from the language (the result being much more similar to Java). Version 3.0 is very far away though, and my plans can change many times until then.

Share this post


Link to post
Share on other sites
I think that might avert a great deal of confusion -- I've had some of my collaborators trip over the present @ semantics. A new operator like ":=" for value assignment might be an order if such a change is made, though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement