So currently I am working in a drag and drop style tree chart program editor for ComputerCraft. I would like to have it fully support custom APIs and detect what variable types should be placed into them in as efficient a method as possible. Currently I'm working with creating a coroutine that rapidly calls the function passing random variable types to see if any attempts don't error out. It can already catch number of arguments needed or unknown number (... In function)
I really don't believe this is possible in any realistic method but I figured maybe someone here can think outside the box enough and give me some ideas. It doesn't need to be a perfect science just a close estimate that's correct at least half the time and I'll just add an easy override for the user to plug anything they want into the box.
Detect what types a function expects
Started by HDeffo, Apr 06 2015 10:19 PM
4 replies to this topic
#1
Posted 06 April 2015 - 10:19 PM
#2
Posted 06 April 2015 - 10:34 PM
I can think of so many things that blind calling a function can do wrong. as for estimating what function needs? Can't think of a way. How about program asking user what function it don't know requires using some kind of setup wizard and remembering what they choose? With an easy override for the user to plug anything they want into the box
#3
Posted 07 April 2015 - 09:14 AM
If I wanted to do something like this, I guess I'd trawl through the actual APIs folder and parse the source directly. Check how many arguments each function expects, then read on further to see what sort of operations are used on them. The catch is that some API functions don't have Lua source available (eg, most of the "turtle" API).
Although he doesn't always do it, and few other coders around here do it at all, Dan often prefixes his variable names with a lowercase character indicating their type.
Although he doesn't always do it, and few other coders around here do it at all, Dan often prefixes his variable names with a lowercase character indicating their type.
#4
Posted 07 April 2015 - 11:24 AM
for things like the turtle API, they are coded on the java side, which means that you can't change them, which means that you could hard code the function argument thing
#5
Posted 07 April 2015 - 11:25 AM
I honestly didn't think about that compiling how it runs the function DUH thanks bomb bloke 
if the function asks for "sText, second, var" and somewhere in the code it does second=second-1 and somewhere it does table.concat(var) we can figure out what variables it needs. This actually looks possible now.
if the function asks for "sText, second, var" and somewhere in the code it does second=second-1 and somewhere it does table.concat(var) we can figure out what variables it needs. This actually looks possible now.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











