Page 1 of 1
[Implemented] Labels local to procedures
Posted: Fri Jun 11, 2010 12:12 pm
by luis
WHAT:
Labels local to procedures.
WHY:
Useful for example to name an exit point LBL_ERROR: and jump to it using GOTO.
This will permit to use LBL_ERROR in any proc without the need to append something to the name to make it unique.
And it will take care of errors while cutting/pasting some code from a proc to another leaving a goto to a label inside another procedure if you forget to update it to the local label.
SEE:
Fred wrote: I will change label's scope to be local to procedure to avoid such syntax.
http://www.purebasic.fr/english/viewtop ... 88#p320088
ATM not available in PB 4.50.
Thanks!
Re: Labels local to procedures
Posted: Fri Jun 25, 2010 11:23 pm
by luis
For now I'm trying to use FASM's anonymous labels (@@) in my (fake) TRY/CATCH constructs.
Unfortunately the use of FASM's local labels like someone proposed in some other thread (a label preceded by a dot like .label) is not feasible because the ASM code generated by PB uses global labels and:
FASM manual wrote:
The label whose name begins with dot is treated as local label, and its name
is attached to the name of last global label (with name beginning with
anything but dot) to make the full name of this label. So you can use the
short name (beginning with dot) of this label anywhere before the next global
label is defined, and in the other places you have to use the full name.
For what I saw PB doesn't use anonymous labels and so this method should work.
Obviously this way one can have only one CATCH point but you can treat different error codes there (the equivalent of real exceptions) with some if/select.
All of this could be avoided if it would possible to generate a unique (and so local-like) label using
#PB_Compiler_Procedure as the base for the name but for what I know
it's not possible. Right ?
Re: Labels local to procedures
Posted: Tue Apr 05, 2011 12:11 pm
by luis
Fred, can you say if we'll have local labels in the foreseeable future ?
I would like to not depend too extensively on the trick above as I'm doing.
Thanks.
Re: Labels local to procedures
Posted: Tue Apr 05, 2011 1:16 pm
by Fred
I had done some work on it for 4.60, but it wasn't finished in time. Could be in a next version, but as always, no promises.
Re: Labels local to procedures
Posted: Tue Apr 05, 2011 4:48 pm
by luis
Thank you for the answer (and naturally for working on it)

Re: Labels local to procedures
Posted: Wed Apr 06, 2011 12:14 am
by ColeopterusMaximus
Fred wrote:I had done some work on it for 4.60, but it wasn't finished in time. Could be in a next version, but as always, no promises.
God bless you.
Please Fred tell me that you're fixing the on error goto jumps too... please please please.