Jump to content

  • Log In with Google      Sign In   
  • Create Account

Jason Goepel

Member Since 15 May 2013
Offline Last Active Sep 18 2014 05:18 AM

Topics I've Started

Ambiguous Enum Comparison

11 September 2014 - 01:15 PM

The following code will produce an error, even though the ambiguity could be resolved.

enum MyEnum1

enum MyEnum2

bool main()
    MyEnum1 e = cNo;
    return e == cYes;

I have attached a patch that resolves the ambiguity.


Integer Division

04 September 2014 - 09:32 AM

The majority of my users write scripts to implement custom mathematical functionality.   It is very common for my users to write expressions with integer literals and assume the math will be floating-point.  For example


double f(double x)


       return x**(2/3) + x**2 + 1;



instead of


double f(double x)


       return x**(2.0/3.0) + x**2 + 1;



Most don’t have any idea what integer division is.  Those with any programming background tend to have experience with Visual Basic or Matlab, both of which always use floating-point division.  I find myself correcting this common mistake frequently, and I only expect it to get worse as my user base grows.


I hesitate to ask, because it would be a departure from C++ behavior, but could AngelScript adopt an Engine Behavior option that would treat the / and /= operators as floating-point division?  We could introduce \ and \= operators to perform integer division (like Visual Basic and Python 3).  I suppose even with the engine option disabled the \ and \= operators could still be of some use.


a \ b; // int(a) / int(b)


Let me know what you think, and let me know if you have any alternative suggestions.  This is a very common mistake that my users make, so I need to do something about it.  Of course, if you agree to the Engine Behavior option, I would provide the implementation.


Thank you for your consideration,


Global Variable Redeclaration

12 May 2014 - 01:28 PM

The compiler doesn't seem to prevent declaring two global properties with the same name.  Is this by design or a bug?

Template Specialization Subtypes

30 April 2014 - 12:02 PM


// interface
int asCObjectType::GetSubTypeId(asUINT subtypeIndex) const
    if( flags & asOBJ_TEMPLATE )
        if( subtypeIndex >= templateSubTypes.GetLength() )
            return asINVALID_ARG;

        return engine->GetTypeIdFromDataType(templateSubTypes[subtypeIndex]);

    // Only template types have sub types
    return asERROR;

If the type is a specialization of a template, the asOBJ_TEMPLATE flag is not set



The templateSubTypes array does have elements though.  Should the search through that array really be guarded by asOBJ_TEMPLATE?


GetObjectType for Instances of Templates

30 April 2014 - 08:05 AM

I have registered template specializations for my array class, for example Array<int>, Array<double>.  In prior versions of AngelScript I was able to make the following call to get the corresponding object type.


This function now returns a null pointer.  There doesn't seem to be any way to get the type of a template specialization from the engine.  Am I missing something, or is this an oversight?