Jump to content

  • Log In with Google      Sign In   
  • Create Account

Sir Ementaler

Member Since 09 Mar 2013
Online Last Active Today, 01:47 PM

Topics I've Started

opCall access violation

21 July 2014 - 08:59 AM

The following script in 2.29.1 and earlier versions:

class foo {
  void opCall(string) {}
void main() {
  array<foo> bar(1);

causes an access violation on attempt to execute. As far as I can tell, the conditions are rather specific and it's required that opCall has at least one string or string reference (or another similar object) argument and it's also necessary for opCall to be called on an array element (or perhaps another reference) rather than a freestanding instance. If the call to opCall is made explicit, i.e. 


the error will not occur either.


funcdef error

21 July 2014 - 08:44 AM

The following script tested in 2.29.1 and earlier versions:

class foo {}
funcdef void bar(array<foo>);

results in following errors:

array (0, 0) : ERR : The subtype has no default factory
filename.as (2, 24) : ERR : Can't instantiate template 'array' with subtype 'foo'

These errors occur for every funcdef declaration that contains an array with a script-declared class subtype either as a parameter or a return value. Contents of the class don't matter, including whether the class contains an explicitly stated default constructor or not. The error information is certainly incorrect as this kind of an array can be instantiated anywhere outside of the funcdef declaration.

Default constructors vs default arguments

22 August 2013 - 05:45 AM

Let's consider a simple class declared within a script:

class foo{

I can create its instances in both of these two ways:

foo foo1();
foo foo2;

Now let's consider a similar class, but give its constructor a parameter that can have a default value:

class foo{
  foo(int bar=0){

This will still be valid:

foo foo1();

But the other line will return an error:

ERR : No default constructor for object of type 'foo'.


This error will also appear in various other cases such as trying to create a temporary copy of an object. I think that constructors which can be called with no parameters should be treated as default constructors.

No matching signatures to 'string::split(const string)'

13 August 2013 - 08:22 AM

The topic title is the error I got when I made an attempt to use the split method from inside a script. The way I call it is really nothing fancy, it looks like this:

string text="Line 1\nLine 2";
array<string> line=text.split("\n");

AngelScript manual lists it as one of methods supported by strings. It's said to be a version 2.21.0 addition along with substr, findFirst and findLast methods, all of which appear to work correctly as opposed to split.

Nameless arguments cannot have default values

03 July 2013 - 05:42 AM

I think the topic name accurately describes the problem I encountered while using AngelScript. It's not a major error, but it bothers me. For reference, C++ standard allows nameless function arguments with default values:

void foo(int=0);

AngelScript supports both nameless function arguments (foo(int)) and default values of arguments (foo(int unused=0) - currently the best substitute, but if this were C++, some compilers would generate a warning about an unused argument), but the above code is for no apparent reason considered incorrect.


Now I realize your first thought might be that something like this is completely useless. I already went through explaining how it can be used to my friend, whose first response was "it really feels like you should be doing whatever you're doing in another way", but who later admitted this solution would be the best one. I don't want to get into detail again; in short, it's about functions that have to fit a certain funcdef, so they support handles of that kind, but at the same time are also meant to be called from code directly.