To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1634
1633  |  1635
Subject: 
NQC ideas
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Thu, 11 Mar 2004 00:39:14 GMT
Viewed: 
4679 times
  
NQC is definitely sticking with its C heritage with respect to semi-colons.
Elisabeth mentioned fancier math and IP features.  Neither of those seem
possible when you consider that the compiler has to generate code that runs on
the LEGO firmware virtual machine which doesn't give you any facilities for
doing much in the way of fancy math or IP stuff.

I am trying to figure out a decent way to support the Spybot stack and
subroutines that can take parameters and call other subroutines.  LEGO
implements support for these features of the Spybot firmware in their Mindscript
compiler.  The way they do this is to push subroutine variables onto the stack
prior to the subroutine call and access each of the parameters via a stack
pointer.  Local variables in a subroutine in the Mindscript language all have to
be declared before any other code in the subroutine (kind of like Pascal).
These local variables are also accessed via the stack (rather than by using the
"local" variables provided by the firmware - which are in very short supply).
Declaring local variables in a subroutine results in adjustments to the stack
pointer value used for each of the subroutine parameters (i.e., the parameters
are pushed further down on the stack).

I'd like to do something like that in NQC for the Spybot target, but in C/C++
you can declare a variable anywhere you like and limit its scope to just a small
subset of the total subroutine scope.  That makes keeping track of the parameter
variable addresses (stack pointer values) very complicated.  Since nobody is
interested in any of this stuff (based on the feedback I've received so far) I'm
inclined to go for a simple solution rather than a complex one.

Would it be too contrary to C/C++ to introduce a construct in NQC which allows
for local stack-based variables to be declared only at the beginning of a
subroutine.  Other variables could be defined anywhere using the existing
syntax, but programmers could take advantage of the stack in the Spybot firmware
using a special keyword that has to occur before any other keyword.  That's one
idea.

Insert your better ideas here.  Especially if you can contribute an
implementation which works with the existing syntax.

I'd still love to hear from anyone who may have tried out some of the new
features in NQC 3.0a2.

Thanks,

John Hansen
http://bricxcc.sourceforge.net/nqc/



Message has 2 Replies:
  Re: NQC ideas
 
(...) Hi John, C is more restrictive than C++ when it comes to variable declaration. In C, you can only declare variables at the beginning of a block before any executable. Well, lets see..... any variables declared outside a function are by (...) (20 years ago, 11-Mar-04, to lugnet.robotics.rcx.nqc)
  Re: NQC ideas
 
(...) I'd say go for it, it is still quite uncommon for C programmers to put their variable declarations elsewhere. Jürgen (20 years ago, 11-Mar-04, to lugnet.robotics.rcx.nqc)

6 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR