Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

GDScript: First-class functions roadmap #23

Closed
vnen opened this issue Jun 21, 2018 · 8 comments
Closed

GDScript: First-class functions roadmap #23

vnen opened this issue Jun 21, 2018 · 8 comments

Comments

@vnen
Copy link
Member

vnen commented Jun 21, 2018

NOTE: All changes for 3.1 were implemented. Changes marked for 3.2 were postponed to 4.0 and will need a review, since it needs more details. I'll leave the original post for reference and link the new roadmap when ready.


Considering the long-standing requsts to support lambdas and first-class functions, and how that needs to break compatibility, here's the roadmap to the next Godot versions to enable the feature.

Related issues/pull requests:

Godot 3.1 (next release)

Godot 3.2 (release after the next)

  • Make functions and class variables to live in the same namespace.
    • This will break compatibility for people using variables and functions with the same name. Though they should be solved after the warnings in the previous version.
  • Allow variables to contain references to functions.
    • This means variables can also be used as functions: var rot = $Sprite.rotate; rot(PI)
  • Add syntax for lambda functions.
  • Add type-hint syntax for functions.

This enables a few consequential features (may or may not be added):

  • Allow connect() to receive a function reference instead of a string.
  • Add map(), reduce(), filter() functions to Array, all receiving a function as parameter.
@jonbonazza
Copy link

And Finalizers???

@vnen
Copy link
Member Author

vnen commented Aug 25, 2018

@jonbonazza it's not on the plans and not related to this topic. You can open a feature proposal ticket with what you have in mind.

@brogan89
Copy link

hi, just wondering if things like "Go To Definition" and "Find All References" are possible for variable and function inspections?

@xDGameStudios
Copy link

xDGameStudios commented Jun 29, 2019

@vnen how is this coming up!? ;)

@tcoxon
Copy link

tcoxon commented Jul 30, 2019

Is this still planned for 3.2?

@payload
Copy link

payload commented Jan 5, 2020

Just found this issue. First class functions are moved to 4.0 AFAIU. https://twitter.com/reduzio/status/1137410475145216000 Or is it more complicated than that @vnen @akien-mga?

@vnen
Copy link
Member Author

vnen commented Jan 6, 2020

What happened is that I pretty much didn't have time to work on this for 3.2. There's also some implementation details discussed after this that would require changes to Variant, so it was preferred to be left for 4.0. The changes listed here will likely be implemented to 4.0 along with other stuff, so this roadmap need to be reviewed anyway.

I'll leave this here for history and add a note explaining the progress. Soon I will work on another proposal.

@vnen vnen closed this as completed Jan 6, 2020
@xsellier
Copy link

Hey,

Sorry for the necro-bump but I don't find any news about First class functions (I don't want to open a new ticket regarding that feature).

I wonder, will it be part of Godot 4.0? (including Array filter/reduce/map)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants