Following the GML Updates blog, we gathered questions from our community and have answered them here.
______________________________________________________________________________
CPAZ - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371067
While on the topic of lightweight objects, I'm curious as to how big in scale they can get. Are there any hardcoded limitations on them? Will they have their own events? Or are they restricted to the event they're made in?
ANSWER - They can hold as many variables as you can put in them, all instances are lightweight objects underneath the hood, the instances just have extra functionality, there are no hard-coded limits on them, they cannot have their own events, you can make them in any event.
______________________________________________________________________________
K-SYS - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371076
Will the "new" operator be also available for "normal" objects, allowing us to write and inherit proper constructors for them?
ANSWER - Instances cannot be created with the new operator.
If not will any other way be added to write and inherit constructors for "normal" objects?
ANSWER - No plans currently. You do have a constructor for instances (the Create Event) and you already have inheritance (use event_inherited() ).
______________________________________________________________________________
NOMMIIN - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371079
Seeing that there is a lot of influence from JS with these new additions, will these changes also bring some helpful JS functions/features such as the spread operator and arrow functions? In addition to this, how would retrieving variables work in GML with these changes? Will it still function the same and throw an error, or will it behave like JS and return undefined if the variable does not exist.
ANSWER – We have no current plans for the spread operator or arrow functions, we must walk before we run. It will still work in the current fashion, though you can use the variable_instance_* functions to check for existence or get/set variables indirectly.
______________________________________________________________________________
GNYSEK - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371090
Can "scripts" resource be renamed, so that wouldn't mislead people after changes? Something like "definitions", or "code" or "functions" or even... "GML" would fit better now, as this is the breaking change in fact (a good one, but breaking), but as we can define macros and enums there - and soon "objects", that would have some sense.
ANSWER - We are discussing name changes internally for clarity and will have an annoucement of these changes when we reach a conclusion..
______________________________________________________________________
ORACIZAN - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371093
How will functions interact with gml_pragma("forceinline")? I would really love to see a YYC / VM inline function preprocessor.
ANSWER - The current “forceinline” will work with all functions - but only with YYC and then at the discretion of the C++ compiler.
______________________________________________________________________
ORACIZAN - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371100
Will there be a difference in the way methods and the built-in GML functions are handled? e.g. however ill-advised it actually is to do so, could I use the new keyword with a built-in function?
ANSWER - We would not advise it, but the language will not stop you from trying it (most built-in functions do not do anything with the ’self’ object which is the point of a constructor), the function called after new can be any valid GMS function.
______________________________________________________________________
URTO - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371106
- Storing functions as a variable makes it seem like creating functions will actually consume runtime resources. If I declare and define several functions in an object's create event and then instantiate the object two, three, or even ten times... does each instance of that object process the function definition? The fact that you can declare functions outside of the create event, such as in step event, makes me worry that the answer is yes, but my hope would be that the compiler is smart enough to recognize that functions declared in a create event should just be bound to the object type and not to individual instances of the object.
ANSWER - Only a very small amount of memory is used for the method itself, it is just a pointer to the actual function information created by the compiler, currently the events on an object cannot be obtained to call them the event_perform() function has to be used so they cannot be bound to a method. In short, a method variable is very small, but there is one created for each.
- If I declare and define multiple functions in a single script resource, will there be a way to bind all functions in that resource to an object instead of having to bind each one individually? It seems like it would be highly convenient for a dev to just make one script resource for an object type which houses all intended functions of that object (I daresay it would even be like OOP). I didn't see anything in any of the examples that would permit this behavior. Some simple function like:
bind_all_functions_in_script(scrPlayerCharacterFunctions);
This would especially be useful if the code completer could pop up with function suggestions only for bound functions, which would A.) remove the need to store a lot of these in variables and B.) reduce clutter in the code completer.
ANSWER - Each function declared in a script file is an individual function, we are not planning on exposing the grouping to the runtime so there will be no way at runtime to locate all functions declared in a single script file, this would have to be done by hand by the user.
______________________________________________________________________
HYOMOTO - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371116
how will this affect defining a function with variable arguments? I didn't see the syntax for that in the examples given.
ANSWER - The current argument_count and argument array will still work as before, that is not changing.
______________________________________________________________________
GMWOLF - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371155
can we nest object literals?
ANSWER - Yes, of course, you can, a lightweight object literal is a valid expression (that returns a lightweight object).
how about functions? can we nest those?
ANSWER - Yes you can, but for visibility, the functions would have to be assigned to a variable and that stored somewhere to be retrieved.
are functions declared in scripts bound to the global instance?
ANSWER - They will be static so not bound to a specific ‘self’, same as scripts currently are.
______________________________________________________________________
PFAP - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371168
Will we be able to JSON encode lightweight objects and send them over the network?
ANSWER - That functionality will come, but may not be part of the initial release, we are working out schedules.
How will methods and factory functions work?
Will we be able to write functions that return based off of the objects state?
ANSWER - The constructor is essentially a factory so you will be able to use that, you can access object state within the function so yes you will be able to write functions that return based off of the objects state.
Will this be valid object literal syntax:
var obj = {
name: "Pfap",
stats: [ 1,2,3,4,5 ],
features: { height: 60, weight: 160, friends: [ 1,2,3,4,5 ] }
}
ANSWER - Yes nested objects are possible
______________________________________________________________________
GMWOLF - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371173
How about reflection on lightweight objects? will we be able to use the variable_* functions on them?
ANSWER - Yes they will work, within the runtime, all instances are based on lightweight objects and all those variable_instance_* functions will work on lightweight objects.
there is a way to rebind functions, but can we get what instances they are bound to?
ANSWER - We can see that being handy, We will look into what can be done, no promises.
Could we disable the garbage collector and get it to run only when its 'safe'/'ok' to run, like at the end of a level, during a cutscene, etc as to minimize its impact on performance when the main game is running? (glad to hear its only running once a frame as to not choke our tight loops)
ANSWER - Once we have finalised the control facilities of the Garbage Collector we will let you know.
______________________________________________________________________
CHES ROWE - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/#post-371195
Would yoyogames ever consider implementing natively something like GMLive by yellowafteraife? I think it would be amazing.
ANSWER - It would, we are concentrating on the work we are doing now to deliver good things for everyone.
______________________________________________________________________
Is this going to affect the html5 export performance in any positive way?
ANSWER - Too early to tell, but we hope so.
______________________________________________________________________
What happens when you call a global-scoped function from an instance? is the global instance bound to that function?
ANSWER - If you mean a function declared in a script file then yes that works just the same as scripts do now, so they do not have a bound ’self’ and use the current ’self’ when they are called, this is what we mean by a static function.
Could you use the . notation on non-method functions? ie:
//Global scope
function doThing() {
x = 10;
}
//some other part of code
inst.doThing();
ANSWER - No that will not be possible but you could do:
inst.doThing = method( inst, doThing );
and then it would be possible to do: inst.doThing();
or you could do:
with( inst ) {
doThing();
}
As you can do just now with any script.
______________________________________________________________________
Someone already asked about variable reflection for lightweight objects (like the variable_* methods), but I'll add method reflection onto that. Can we have something like method_get_name & method_get_argument_names?
ANSWER - methods do not have names and there will not be any reflection on the underlying functions, so not in the way you are asking. We think that it is important to point out that there are really 2 things happening here we have 1) functions that act just like scripts have done up to now and 2) methods that are a binding of a function and either a lightweight object or an instance, so the reflection on a method could only yield either the function reference or the reference to the lightweight object or instance. We do not provide reflection on functions as the runtime does not hold that information in a way that is accessible, that is lost after compilation.
Can we use the new keyword with standard objects in any way? Being able to give defined objects their own constructors would be very handy.
ANSWER - You already have constructors for standard objects see Create Event.
______________________________________________________________________
FrostyCat - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-2#post-371272
Chained Accessors
* When chained accessors were last discussed, the promotion of data structures to true types was stated as a prerequisite. Has this been done?
ANSWER - We have found a way to do it without that as a prerequisite, this is good as that is a lot of work that would just delay these features.
* Can accessors chain with the dot operator (e.g. foo[1].bar)?
ANSWER - Yes.
* Can accessors chain with the method syntax (e.g. foo[2]("bar"))?
ANSWER - Yes.
Function Type
* If a parameter name conflicts with an existing instance variable name, which wins? Example:
a = "foo";
var log = function(a) {
show_debug_message(a);
}
log("bar"); // foo, bar or no compile?
ANSWER - The standard GML scoping rules apply here so all names are resolved internal to the function declaration (the arguments are part of that), the function block has no knowledge of the outer code and so cannot resolve names within that, anything unknown would be assumed to be resolved on the current ’self’, which would be a runtime error if not present. In your example, the a in the show_debug_message in the function would be the argument and not the outer instance variable.
* How will a var keyword used inside a function definition be scoped? Will the current "pull-up" behaviour still apply, or will this get new handling?
var func = function(a) {
var b = "bar";
show_debug_message(b);
return a+1;
}
func(0);
b = "baz"; // Is this local- or instance-scoped?
ANSWER - The inner declaration of var b is only scoped within the function declaration so the outer b would be ’self’ scoped.
* If two var statements have a name conflict, and one is inside a function definition and the other outside, what happens? Will this be allowed to compile, and if it is, which wins? Example:
var a = "foo";
var log = function(b) {
var a = "bar";
return a+string(b);
}
show_debug_message(log("baz")); // barbaz
show_debug_message(a); // foo, bar or no compile?
ANSWER - As above each function body is distinct and the inner one does not ’see’ any of the declarations outside, so the final show_debug_message would show foo.
* Will Auto-Complete be smart enough to hint parameter variables only when the cursor is between the function's braces?
ANSWER - It will work much the same way as it does now.
* Will Auto-Complete refrain from suggesting methods belonging to foreign objects?
ANSWER - No as these could still be accessed.
* How are optional arguments now handled?
ANSWER - As they currently are using argument_count and argument array.
* How are functions with an arbitrary number of arguments now handled?
ANSWER - As they currently are using argument_count and argument array.
* If given a function-type value, what will typeof() and string() return? And are other type-conversion functions prepared to handle this?
ANSWER - We will have complete documentation when the feature is delivered, these details are not finalised yet.
* If a script-global function is stored in an instance variable, is it legal to call it from another source? Example:
// In a script
function foo() {
return x;
}
// In obj_a's Create event
goo = foo;
// In obj_b
bar = obj_a.goo(); // Is this legal? If it is, whose x does it return?
baz = method(obj_a, goo);// Is this legal? If it is, whose x does it return?
ANSWER - OK we will need to break this down a little so the function foo in the script will act as a current script so it has no bound ’self’ it is not a method variable and the assignment of foo to goo will work but it will be getting a function reference which currently is like a script index, this means that the line bar = obj_a.goo() would not work as obj_a.goo is a number and not a method, currently this is not allowed and you would have to use execute_script( obj_a.goo ) to actually execute that, the baz assignment would work though as method can take the script index to complete the binding. The x that is returned, if baz() is called, will be the x variable contained in the first instance of obj_a (assuming that obj_a is the name of an object resource) that is found and bound by the method call.
Multiple Functions in a Script
* How will GMS 2.2.3 tell unconverted old scripts from new scripts that has code intentionally not placed in a function() declaration, just to run on startup?
ANSWER - In any old projects that are unconverted the body of the script would be copied completely, the project will be updated and recognised as not needing further conversion on load.
* What will happen to script_execute(), now that multiple subroutines can go inside the same script?
ANSWER - It will work as before and the function names can all be used as script indices.
* Will there be something like script/function_execute_params(f, arr) where an array of parameters are expanded to function parameters, so that arbitrary-parameter functions can be called with runtime-built arguments? (the "17-case-script_execute()" hack isn't general enough anymore)
ANSWER - We will discuss internally introducing that as a feature request.
* What will the role of asset_get_index() be for script names from now on? Will it support function names instead?
ANSWER - asset_get_index() will know about all non-anonymous function names.
* How are optional or arbitrary arguments now handled? What will happen to existing scripts that already take arbitrary arguments (i.e. use the argument[n] syntax)?
ANSWER - The current syntax is still valid, using argument_count and argument array.
* Will this supercede the clunky "add arguments in a GUI" system currently used in the extensions mechanism for GML extensions?
ANSWER - Overhauling the extensions mechanism is something we plan to do later, it is not happening as part of this update.
Lightweight Objects
* What would inheritance look like with "lightweight objects”?
ANSWER - To inherit B from A then in the constructor function for B then just call the constructor for A, i.e.
function A()
{
}
function B()
{
A();
}
var b = new B();
* What does the static scope syntax look like with "lightweight objects”?
ANSWER - This is not finalised.
* Are there plans for adding OOP interfaces for existing non-primitive types (e.g. resource tree types, data structures, buffers, etc.), particularly "orphaned" types like matrix, vec3 and vec4?
ANSWER - That is a larger question and we will be updating the whole runtime in the future, but in order to do this we are changing the language first to accommodate this style before we revamp the whole runtime to add more OOP style functionality.
* Will the built-in JSON functions transition to working with lightweight objects and arrays, as opposed to maps and lists? Or will they both be more or less equivalent in terms of behaviour with the garbage collector?
ANSWER - The current functions will continue work as they do, we will introduce new functions to handle lightweight objects and arrays.
* Will overloading operators, iteration/indexing, serialization (i.e. what string() would return if given as the argument), cloning, and boolean casting be supported? This is important for types that have well-defined mathematical operations (e.g. vectors and quaternions) or see frequent serialization (e.g. virtual board states).
ANSWER - We have no plans for overloading these compiler level constructs, we want to provide these improvements in a reasonable timeframe.
* How will different types of lightweight objects be distinguished from each other? Certainly, typeof() wouldn't help as its proposed behaviour would just return "object”.
ANSWER - We will have the equivalent of instanceof that will allow users to tell which constructor was used to create a lightweight object.
* Are there plans for renaming what we now call Objects to something like "Actors" to avoid future confusion?
ANSWER - We are discussing renaming internally, it has been a continual problem for us that these were co-opted names in a non-standard fashion in the early days and this has persisted.
new Operator
* Are any existing resource types (e.g. data structures, buffers, etc.) retrofitted to support the OOP way of initialization?
ANSWER - Not in our first iteration, we will be revamping these in the future.
* Would using var inside of the function effectively give a "private" method or field?
ANSWER - No local variables cannot be seen outside of the function body so they cannot be co-opted in this style.
* The current proposed syntax presents a risk of unwanted behaviour if the new operator is omitted. For example:
function Vector2(_x, _y) {
x = _x;
y = _y;
mag = function() {
return sqrt(x*x+y*y);
}
}
From here both var v = new Vector2(0, 0); and var v = Vector2(0, 0); are legal if called from within an instance (the latter questionably so only because of the default return value), but the latter will silently do unwanted behaviour. Would you introduce some sort of class keyword to prevent the second call from compiling, or let it slide and become a logic bomb, or handle it some other way?
ANSWER - We will address this as a warning in the IDE when functions that are marked as a constructor (details will follow on how this will be done) are used outwith a new operator or functions that are being used in other code as constructors are called in a normal way, note: it would still be legal to call a constructor function directly from within another constructor.
* If you do introduce the class keyword and make the distinction, the new operator would become a meaningless filler. Would you be open to OOP without the new operator? This would open the possibility of semantic, in-line data modeling similar to what GMSugar currently does.
ANSWER - We have no plans in this update to introduce a class keyword.
Exceptions
* How are custom exceptions defined?
ANSWER - There is no definition for an exception, like javascript the argument to the throw is a variable that can be anything.
* Is there always one catch to a try, or can there be multiple catches for different types?
ANSWER- Exceptions are typeless so there is no point to multiple catches, just like javascript.
* What kinds of code are allowed for handling an unhandled exception?
ANSWER - The unhandled exception handler will be a function itself, it will not be possible to draw inside that so the main job would be to flag to the rest of the code that something has happened and the user needs to be informed, ie change room or create an exception handling instance that renders info to the screen for the user.
* What happens if code for handling an unhandled exception throws an unhandled exception of its own?
ANSWER - We will have a default handler that will inform the user that multiple exceptions have occurred, it will not be possible to recover from that.
* For catastrophic errors or unhandled exceptions requiring asynchronous follow-up (e.g. submitting error logs to a server, integration with error reporting software such as BugSplat, etc.), what hooks/mechanisms are available?
ANSWER - See answer above, this would be handled in the normal GMS2 flow.
Garbage Collector
* Will data structures be garbage-collected?
ANSWER - Not initially until the work is done to make them references, which will allow them to be garbage collected.
* Will circular references be garbage-collected? Example:
var a = [0],
b = [a];
a[@0] = b;
a = undefined; // Will this allow a and b to be GC’ed?
ANSWER - Yes this is the primary reason for having a garbage collector.
* In addition to current primitive GML types, strings, arrays and destroyed instances, what else are garbage collected?
ANSWER - All lightweight objects and methods.
* Does implementing the garbage collector imply the promotion of any other dynamically allocated resource (e.g. buffers) to a true type, away from numeric indexing?
ANSWER - This will happen over time, the goal is to have all of these internal types to be references that can be collected.
On-Boarding Concerns
* Will YoYo release red builds to educators and power users sometime in Q3, so that they can create learning materials for the new syntax additions ahead of time and help spur adoption that way?
ANSWER - Yes we will have a Closed Beta programme through Q3 that will be opened up gradually to more and more developers with a public Beta release towards the end of Q3 into Q4.
* What happens to existing GML extensions on the Marketplace that have not been adapted to the new syntax?
ANSWER - All current syntax will be valid, so they will still work.
* What use cases for these new syntax elements have YoYo developers tested against? Will the internal test suite be open-sourced in ahead of time to help document that in an applied sense?
ANSWER - We are testing them internally on our test suite, we have not announced yet when or if this will opened up to the public.
* A lot of current advice on data organization will be obsolete following the GML 2.2.3 revamp, and you can be sure there'll be smart-alecs in 2020 trying to bump up old topics "advising" our 2017 selves. Will automatic topic closures be in place to prevent misinformation from spreading on the GMC?
ANSWER - We will need to have further discussions and make some decisions. We will have more information to share closer to the time.
______________________________________________________________________
CODED GAMES - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-2#post-371312
Are there any changes to functions like script_get_name, script_execute, or script_exists?
ANSWER - We have not finalised those changes yet.
______________________________________________________________________
How will we be able to test if a lightweight instance has a variable? Would that have to be done through varaible_* functions, or could we get a keyword to test it? It would be useful to do cool ducktyping things.
ANSWER - The variable_instance_* functions will work on lightweight objects as well as instances.
______________________________________________________________________
XANTHORXIII - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-2#post-371382
Is there going to be a dedicated space for declaring functions in a project. I’d almost like to see some assignable header like file that we can create and assign to objects separately
ANSWER - Functions can be declared at any point in GML so this is not something we can enforce but you can organise the code as you wish. We will allow methods to be declared in the object editor in a similar way as Events can be declared now.
______________________________________________________________________
if I want an input object that reads my hardware every frame, a camera object to update the view, etc. how do I do that? Lightweight objects appear to just be storage containers. Can they perform logical operations, comparisons, etc.? Do I just need to use a normal object and in its step event tell the lightweight objects to do something each frame? Do the new functions/methods help here somehow? Sorry if I'm missing something here, but again I have a pretty limited background in programming.
ANSWER - The new features we discuss here can be used in many different ways, closer to the time we will give more concrete examples and pass this information onto our communty of tutorial creators to explain how they can be used by everyone.
______________________________________________________________________
TTHECREATOR - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371431
Any changes or ideas for polymorphism and inheritance? I'd be great to at least be able to implement the functions from another light object.
If we don't get that then what we get is probably is just an error when a function is not implemented and you try to call it. GML is not a strongly typed language anyways so you would just be able to use any object anywhere. Still some of programmings industry standard 'best practices' are not possible in GM.
ANSWER - It will be possible to clone one lightweight object into another and copy all the methods and it will be possible to create an interface by having dummy methods in place, not 100% sure what you are really asking here but both polymorphism and inheritance will be possible.
______________________________________________________________________
FrostyCat - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371462
Encapsulation
* Will there be the equivalent of a protected and/or private scope for methods and fields?
ANSWER - GML is a beginners language and we feel strongly that protected and/or private scoping does not help in that regard, but we are evaluating various ways for extension authors to hide implementation details, we are not in a position to talk about this just now and the initial release of these language changes will not include any visibility scoping.
* What happens if you set a previously inexistent field for a lightweight object after it has been instantiated? Example:
function Vec2(_x, _y) {
x = _x;
y = _y;
}
var foo = new Vec2(0, 0);
foo.z = 0; // What will the runner do about this?
ANSWER - This will just be added to the lightweight object in the same way as it currently works in GML, the lightweight object is not sealed.
* What happens if you initialize a field to function type value (i.e. making it a method), then assign it another value (could be a function or a non-function)? Example:
function Vec2(_x, _y) {
x = _x;
y = _y;
mag = function() {
return sqrt(x*x+y*y);
}
}
var foo = new Vec2(0, 0);
foo.mag = 0; // What will the runner do about this?
ANSWER - The variable mag inside the lightweight object foo is assigned the value 0 just as it currently would, the object is not sealed.
Inheritance
* If the new GML allows "lightweight object" types to inherit from each other, how will children call their parent's original implementation of a method after overriding it (i.e. the equivalent for the super keyword in Java)?
ANSWER - They would have to take a copy of it and call that function directly.
* Can you implement "mix-ins" in global functions to be executed in "lightweight object" definitions? Example:
function ExampleMixin() {
say = function(message) {
show_debug_message(message);
};
}
function Vec2(_x, _y) {
ExampleMixin();
x = _x;
y = _y;
}
var v2 = new Vec2(0, 0);
v2.say("Hello world!"); // Is this allowed?
ANSWER - Yes, that is how inheritance and traits/components could be implemented.
* If the new GML supports a private scope, how will it protect against a child accidentally overriding a private method/field of the same name in its parent? This may happen in an extension setup, where the end user would not be aware of what private method/field names to stay away from.
ANSWER - We are planning on addressing sealed and read-only variables beyond this initial release, but have plans on how to handle this scoping.
Polymorphism
* Will duck-typing be the main manifestation of polymorphism in the new GML update, as I predicted?
ANSWER - We will have an instanceof that can be used to determine a lightweight objects initial type but duck typing can be used as well.
* Can you alias methods? Example:
function Vec2(_x, _y) {
x = _x;
y = _y;
mag = function() {
return sqrt(x*x+y*y);
}
norm = mag;
}
var v2 = new Vec2(3, 4);
show_debug_message(v2.mag());
show_debug_message(v2.norm()); // Is this allowed?
ANSWER - Yes.
* Will there be syntax that enforce the implementation of certain properties without providing an existing implementation (e.g. the interface keyword in the C++/Java lineage)?
ANSWER - No.
______________________________________________________________________
TTHECREATOR - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371468
Has strong typing been considered? Are there any future plans for it?
ANSWER - Yes. Not currently.
______________________________________________________________________
Metatables / Metainstances. could they be worked into the mix?
ANSWER - If you mean static function on a lightweight object then yes they will be available.
______________________________________________________________________
CLOAKED GAMES - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371503
- How will inheritance work with lightweight objects?
ANSWER - A constructor can call another constructor (or many constructors) this would be inheritance.
- Will we be able to use polymorphism (or something with similar functionality) for better OOP code organization?
ANSWER - Yes.
- Can we use dot notation to run methods, such as inst.method()? Or will we still need to use with(inst) { method(); }?
ANSWER - Yes the dot notation will be used (see the examples in the blog post), though the with method would be valid too.
______________________________________________________________________
IMMORTALX - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371510
Would you consider adding some sort of optional typing?
ANSWER - It was considered, we decided against it.
______________________________________________________________________
Is there any plan to shorten the existing functions' names? e.g. instance_create_layer() can be shortened to instance_create() , even if it continues to have 3 variables.
ANSWER - Not in this update.
______________________________________________________________________
how will instances and functions interface with the C interface? Will we be able to create and populate lightweight objects in DLLs?
ANSWER - There is no change to DLL interfacing with this update.
______________________________________________________________________
FrostyCat - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371660
After the GML 2020 update, what are the type correspondences between GML-native types and native extension types for each export platform? And if there are GML-native types that don't interoperate directly, will there be runner hooks that allow native extensions to have limited read/write access to those types?
ANSWER - There is no change to DLL interfacing with this update, or to how we handle native interfacing.
______________________________________________________________________
Big_Macca_101 - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371737
With the addition of lightweight objects and functions, will we have an official way of doing namespaces at all? Because yes we could do globalvar but I think we all know why that isn't ideal
ANSWER - We are not announcing anything around namespaces but these features can be used to give better encapsulation of functionality.
When the 'new' operator and lightweight objects are added as well as the foreach statement, will we be able to check for lightweight objects as if they were classes?
ANSWER - Yes.
______________________________________________________________________
SRPSKICEKIC - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371917
Do you have plans & your thoughts on Multi-threading support in GMS2? Also, the same question about run-time code compile?
ANSWER - Yes we are not announcing anything about this at this time.
______________________________________________________________________
TTHECREATOR - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-3#post-371986
If I make a new lightweight object 'a' using the new keyword, and then say 'b=a'. Do I then have a copy of the object or a reference to the object in b?
ANSWER - You have a reference.
______________________________________________________________________
Will functions of similar names but different arguments be allowed? As in:
function Vector(x, y, z) {
self.x = x;
self.y = y;
self.z = z;
}
function Vector(x, y) {
self.x = x;
self.y = y;
}
ANSWER - No, though your functionality can be accomplished using argument_count and then doing.
function Vector(x, y, z) {
if (argument_count == 3) {
self.x = x;
self.y = y;
self.z = z;
}
else if (argument_count == 2) {
self.x = x;
self.y = y;
} else {
throw “Vector Argument Error”;
}
}
______________________________________________________________________
A question about the chained-accessors.
Does this include chained results from function. Like a function returning a ds_list
Eg.
var _rarity = item_get( _i )[| ITEM.RARITY ]
ANSWER - Yes that will be possible.
______________________________________________________________________
DOG SLOBBER - https://forum.yoyogames.com/index.php?threads/gml-updates-in-2019-follow-up-ama.61623/page-4#post-372073
[two related questions]
- Will variable number arguments be supported within methods with argument_count, arugument[0 .. max_num]?
ANSWER - Yes just as it is now.
- When using user-defined argument names will an unreferenced argument_name generate a warning or a run-preventing error as an unreferenced argument_n currently does?
ANSWER - It will work similarly to how it does now.