locked
Local variables and function RRS feed

  • Question

  • Will SmallBasic get local variables and functions?
    I think otherwise it is too resrtricted.
    Sunday, April 5, 2009 9:30 PM

Answers

  • As of now, It seems that Small Basic developers want to keep Small Basic very simple and don't want to add local variables.
    I don't say I agree with that, but it's at least comprehensible.

    However, I think functions are very great to have in SmallBasic, so we can hope that SB4 will support these.

    By the way, I've another idea for local variables :


    ' X doesn't exist here

    Local X, Y X = TextWindow.ReadNumber()
    Y = X ^ 2
    TextWindow.WriteLine("Square of " + X + " is " + Y) EndLocal






    ' X doesn't exists anymore, as Y
    Regards,
    Fremy


    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Monday, April 6, 2009 10:25 AM

All replies

  • As of now, It seems that Small Basic developers want to keep Small Basic very simple and don't want to add local variables.
    I don't say I agree with that, but it's at least comprehensible.

    However, I think functions are very great to have in SmallBasic, so we can hope that SB4 will support these.

    By the way, I've another idea for local variables :


    ' X doesn't exist here

    Local X, Y X = TextWindow.ReadNumber()
    Y = X ^ 2
    TextWindow.WriteLine("Square of " + X + " is " + Y) EndLocal






    ' X doesn't exists anymore, as Y
    Regards,
    Fremy


    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Monday, April 6, 2009 10:25 AM
  • I agree that function are slightly more important than local variables.
    But being simple from the users point of view and having local variables is no contradiction at all.
    It is less simple for developer, but not for users.
    But for an educational project, users REALLY SHOULD MATTER.
    Tuesday, April 7, 2009 9:29 PM
  • As a teacher I would really find it useful to have parameter passing, functions and local/global variables.  As the kids get better at the language and start writing more detailed programs a very common error is they reuse a variable improperly.  If they had to declare their variables and if the variables were local with-in subroutines it would be easier.  Also the step from SB to VB/C++/C# would be a little easier.  I use SB as a tool that leads to other languages so having it share more with the common languages is useful to me.  For those that use SB as their one and only (i think they are rare) the added feature would not be that critical.  On the other side of the argument I really like the simplicity of SB.  When I teach VB or C# the kids end up buried in syntax, properties, IDE management and what got saved where.  Programming with SB is like cracking a walnut with a brick, it ain't pretty but it gets the job done and it sure feels good.
    Wednesday, April 8, 2009 2:42 PM
  • I think Functions should be added to Small Basic.

    SB is about simplicity right?

    Trying to substitue Functions with Sub is not simple (trust me, I tryed ;P )


    Just my 2 cents worth :D
    Tuesday, August 25, 2009 10:13 PM
  • I vote for having functions and the ability to pass parameters to subs and functions.
    Wednesday, September 9, 2009 8:31 PM
  • yes local variables will help a lot.
    To keep it simple, variables should always be local, so I object the idea of a "Local"-statement.
    This yields the necessity of parameters, because without global vars there is no other way of exchanging data between subs.
    To keep it simple, arguments should always be byval, which again yields the necessity of functions as the only way to return values from subroutines.
    I don't like the idea of having a "Function" keyword as Subs and Functions are more or less the same. Subs could have an optional return statement instead.
    Of course there are other ways, which may seem easier. We could have Locals and Globs and no need for functions and parameters. But it seems that it never had been a good decision to do that.
    These subjects are all connected and there should at least be no quick solutions for the moment which will screw the whole thing in the end.
    So take your time and do it right!

    Wednesday, October 28, 2009 11:22 AM