asEP_ALLOW_IMPLICIT_HANDLE_TYPES and OMG!

Started by
3 comments, last by cellulose 11 years, 5 months ago
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.
Advertisement
The implicit handle feature is just experimental at the moment. Unfortunately it only works for script declared classes, and not registered classes.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

what are you going to do next in this area?
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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.

This topic is closed to new replies.

Advertisement