Jump to content

Start from a main routine: Difference between revisions

Added Quackery.
(Added Arturo implementation)
(Added Quackery.)
Line 349:
=={{header|PureBasic}}==
PureBasic is procedural and any code which is not part of a procedure is considered 'main' code. This code also does not use any explicit syntax (i.e. a 'main' module) to cause it to execute and it always executes first.
 
=={{header|Quackery}}==
 
To run the Quackery shell (i.e. REPL) type <code>quackery</code> in the OS monitor app.
 
To run a Quackery program from the monitor, type <code>quackery [program-name].qky</code>
 
To run a Quackery program from the Quackery shell, type <code>$ "[program-name].qky" loadfile</code>.
 
To run the Quackery shell from a Quackery program, include the word <code>shell</code> in the program.
 
To run a Quackery program from within a Quackery program, include the phrase <code>$ "[program-name].qky" loadfile</code> in the program.
 
To run a Quackery program during compilation of a Quackery program, include the phrase <code>[ $ "[program-name].qky" loadfile ] now!</code> in the program.
 
To run the Quackery shell from within the Quackery shell, type <code>shell</code>.
 
To run the Quackery shell during compilation within the Quackery shell, type <code>[ shell ] now!</code>.
 
Other variations are possible. To illustrate this, here is a program which, if typed in in the shell, or included in a <code>.qky</code> file, will temporarily suspend compilation to interact with the user. <code>constant</code> includes the functionality of <code>now!</code> but treats the top item of the stack as if it were part of the program text.
 
<lang Quackery>[ say "Please use the shell to calculate a value" cr
say "and leave it on the stack. Type 'leave' when" cr
say "when you have done this." cr
shell ] constant is my-value</lang>
 
Demonstrating this in the Quackery shell. Text after the duck's head prompt and the continuation ellipses is entered by the user.
 
<pre> > quackery
 
Welcome to Quackery.
 
Enter "leave" to leave the shell.
 
Building extensions.
 
/O> [ say "Please use the shell to calculate a value" cr
... say "and leave it on the stack. Type 'leave' when" cr
... say "when you have done this." cr
... shell ] constant is my-value
...
Please use the shell to calculate a value
and leave it on the stack. Type 'leave' when
when you have done this.
 
/O> 123 456 +
... leave
...
 
Be seeing you.
 
 
Stack empty.
 
/O> my-value echo
...
579
Stack empty.
 
/O> leave
...
 
Auf wiedersehen.
 
 
> </pre>
 
 
=={{header|Racket}}==
1,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.