LB Booster
« Subtle difference in scope rules »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 04:24am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Subtle difference in scope rules  (Read 672 times)
Rod
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 110
xx Re: Subtle difference in scope rules
« Reply #1 on: Sep 2nd, 2014, 6:02pm »

But your sub comes across an exit sub and does not wait in the sub so the scope is back to the main program wait? So I would expect the lb4 result I would not expect LBB result.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Subtle difference in scope rules
« Reply #2 on: Sep 2nd, 2014, 7:34pm »

on Sep 2nd, 2014, 6:02pm, Rod wrote:
But your sub comes across an exit sub and does not wait in the sub so the scope is back to the main program wait? So I would expect the lb4 result I would not expect LBB result.

There are two common applications of scope: 'lexical' (static) scope and 'dynamic' scope, as described in this Wikipedia article:

http://en.wikipedia.org/wiki/Scope%5F%28computer%5Fscience%29

Lexical scoping is the most common in modern programming languages: the scope is determined at compile time according to where in the source code the identifier is referenced. It is clear that, using this definition, the way LBB works is correct.

What you seem to be describing is 'dynamic scope', which is used by a few languages, notably Lisp and Perl, although the situation I described is not typical of the way in which dynamic scoping is generally applied (one function calling another).

Realistically it would be impractical for LBB to work any other way, and in my opinion it is highly desirable for the destination of the 'trapclose' to be determined at compile time (i.e. be predictable) rather than at run-time (and be potentially unpredictable). It also accords with the principle of 'information hiding'.

But a well-written program ought not to depend on this behaviour anyway. As I said, simply omitting the label within the subroutine makes the program work just the same in LB4 and LBB.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls