Unorganised notes about programming in Exodus

From NEOSYS Dev Wiki
Jump to navigationJump to search

c++ exodus

if you are only familiar with c then c++ has some improvements for examples like you can declare your variables at the point they are used (and not at the top of the routine like c)

unlike many modern languages c++ retains the infamous goto statement making porting from pick basic much easier. you have to avoid declaring new variables (var xyz) within the scope of the jump but this is easily accomplished by moving the declaration just above the jump zone.

better to put print(a," ",b) than print(a^" ""b) because faster to do three outputs instead of two concatenations and one output

The following will compile but give throw "unassigned variable" on execution.

var foo=foo.sum();

strings must all be wrapped in " double quotes and single quoted strings are not allowed - except for single character strings. To puta double quote character within a string you must prefix them with \ to be like \".

note the double backslashes in regular expression strings (until we get the R string prefix for "raw strings"

word.match_regex("\\d+")

swap, match and index have an additional argument that can contain r for regular expression and ri for case insensitive regular expression

using comparison (boolean) as 1 or 0 is not supported so "xxx+(a==b)" isnt allowed. put "xxx+(a==b?1:0)"

better than pick basic

there are a series of compromises in exodus design which are forced by the limitations of c++ syntax. with time you get used to these.

offset against the disadvantages are many advantages at multiple levels:

local subroutines have a) parameters and b) local variables

gosub/return style local subroutines can have parameters and their variables are private by nature. this allows monolithic programming with many subroutines in one file/compilation unit without all variables being global.

one way of looking at this is that you can now put all your associated external routines in the main program text and are not required to use separate edit/compile to get parameterisation and private variables.

another way of looking at this is that what used to be your external functions and subroutines (but are now are implemented as internal functions) now have access to the global variables of your main program without requiring setup of common variables.

many functions and subroutines per file

pick only allows one function or subroutine per file. c++ is happy with many. editing and compiling groups of associated subroutines and functions in a single file makes it easier to manage your source code base.

faster conditional expressions

the AND and OR operators "short circuit" ie do not evaluate the right hand side if the evaluation of the left hand side predetermines the final result. For example, in the evaluation of "aa() and bb()", if aa() returns false then bb() will never be evaluated.

multiple programming paradigms

object orientated programming - if you want. functional programming - if you want. procedural programming - if you want.

for application level programming you can follow a standard of only including the exodus header file and not including any of the traditional c++ headers like <iostream>, <string>, <vector> etc. This way you limit the complexity of what the application programmers can do.

If you want to merge pick with traditional c++ programming you are free to include and header files you like. Just make sure to include the exodus.h AFTER all the other headers.

many operating system utilities can be programmed directly in c++ allowing you to do system programming in pick basic syntax

OS level command shell

the bash command line shell treats various characters specially including " ' ( ) < > $ ! and others. You must escape/prefix them by \ to stop bash from messing with them.

so

list file with field = "xxx" (S)

becomes

list file with field = \"xxx\" \(S\)

or you can quote everything after the first word of the command. Single quotes allows all special characters to be used. Double quotes allows bash to continue to mess around with special cdoing macro expansion etc.

list 'file with field = "xxx" (S)'

list "file with field = 'xxx' (S)"

exodus allows the use {} can be used for () brackets if at the end of the command