Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with inlined function calling a taskfunc with an argument #97

Open
ghost opened this issue Apr 1, 2018 · 2 comments
Open

Issue with inlined function calling a taskfunc with an argument #97

ghost opened this issue Apr 1, 2018 · 2 comments
Labels

Comments

@ghost
Copy link

ghost commented Apr 1, 2018

Some code should explain it better:

function ks_function
	tcm_function(1)
end function

taskfunc tcm_function(param)
	message(param)
end taskfunc

on init
	tcm.init(10)
	declare ui_switch switch
end on

on ui_control(switch)
	ks_function
end on

Compile error: wrong number of parameters to tcm_function. Expected 1, got 0
works if you 'call' ks_function.
Works if the functions are declared after 'on init' and after 'on ui_control(switch). So why not do that? Because it's a bit messy and it might affect larger projects.

@mkruselj
Copy link
Collaborator

mkruselj commented Aug 12, 2018

I think tcm.init() needs to be defined in ICB before a taskfunc is defined, so what you did above is throwing the compiler off.

By the way, you should be using a macro in your example rather than a function (for ks_function). Then it works.

@eitherys
Copy link
Collaborator

eitherys commented Apr 13, 2020

Technically, this should not create an error. I will leave this issue open; in the meantime, I recommend always including functions after the init callback. We manage a lot of large projects and this isn't an issue for us, the main idea is to create a "build file" that assembles all your callbacks and functions as imported macros from other imported files. This lets you write code the way you desire in other files, while assembling it in a more standard order for the compilation order.

To clarify, this is now possible, because tcm.init() was just improved in the latest versions of SublimeKSP to support tcm.init() in imported files.

@mkruselj mkruselj added the Bug label Mar 29, 2022
@mkruselj mkruselj changed the title compile problem with taskfunc when declared before on init Issue with inlined function calling a taskfunc with an argument Mar 25, 2023
@mkruselj mkruselj changed the title Issue with inlined function calling a taskfunc with an argument Issue with inlined function calling a taskfunc with an argument Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants