Procedures are not compiled unless they are called from SB

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
erion
Posts: 9
Joined: Fri Mar 03, 2017 8:16 pm

Procedures are not compiled unless they are called from SB

Post by erion »

Hello,

As the subject says: if a procedure is not called directly from SB, it will not be compiled into JS code. Please see the following code:

Code: Select all

Procedure ProcA()
!alert('Procedure A');
EndProcedure

Procedure ProcB()
!alert('Procedure B');
EndProcedure

! f_procb();
This produces a reference error in Firefox. Examining the compiled JS file, we can see that neither ProcA as 'f_proca' or ProcB as 'f_procb' are in the code.

SpiderBasic should either compile all the procedures defined, or make this customisable.

Erion
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Procedures are not compiled unless they are called from

Post by Peter »

this is not a bug. It's a part of the code optimizing process.

See also: http://forums.spiderbasic.com/viewtopic ... 2852#p2852

Greetings ... Peter
erion
Posts: 9
Joined: Fri Mar 03, 2017 8:16 pm

Re: Procedures are not compiled unless they are called from

Post by erion »

Hi Peter,
I thought so, but I really believe that this should be customisable. Interacting with third party libraries would be a lot easier. In Go, for example, declaring but not using a function is considered a compiler error. If SB has inline JS support, it should really scan for at least procedure name mentions in lines starting with an exclamation mark.

Optimisation is good, as long as it does not affect the user experience. If I know that my code does not have unused procedures, I do not need this kind of optimisation. PureBasic, for example, does this with variable bounds checking, etc. Please, Fred, make this an option that we can set in Compiler Options, for example 'Remove unused functions', or something similar.

Erion
Post Reply