Yuce's Blog

Cognitive dissonance is yoga for the brain.*

Freeeze for Marvin3


Today, I added a keyword called freeze to Marvin3. Basically, when called inside a routine, it pops the top element from the stack and replaces routine's code with a word that pushes that value onto the stack. This way we can create a write-once routine, which is similar to C#'s readonly modifier (value is allowed to be set once). Consider the following example:

:YOUR-NUMBER input int freeze ;

"Enter a number:" prints YOUR-NUMBER
YOUR-NUMBER " is a nice number!" cat println

Notice that, although YOUR-NUMBER is a routine, when called, it just pushes the same value determined when it is first called.

Here is a more complex one. continue.


99 Bottles of Beer in Marvin3


How to write 99 bottles of beer in Marvin3?

:bottles  dup dup 1 > [" bottles"] [" bottle"] ifte cat ;

    bottles dup " of beer on the wall," cat println
    " of beer. " cat println
    "Take one down, pass it around." println ;

:theend  "No more beer left." println ;

:beers  [dup 0 >] [sing decr] while theend eat ;

# start singing
99 beers

Also you may check a previous post for the original Marvin. Other languages? 99 Bottles of Beer on the Wall lists many. See 99 Bottles of Beer on Wikipedia.

marvin3, marvin, 99 bottles

Marvin3 is launched


Marvin3 is a new cross-platform stack-based language developed in Python. Marvin3 features object-oriented-pro­gram­ming, anonymous routines, eager lists, variables, lexical scope, com­bi­na­tors and support for modules.

This is from my Marvin3 project home. Marvin has evolved into Marvin3 and is becoming ready to be tried by the audience. In order to make it better known, and because it is free software, I requested a Source­Forge account yesterday, and to my surprise my request was approved in a couple of hours (while I was led to believe that it would take two days!!!). Well, I am happy for that, and I released Marvin3 0.0.6 which has some continue.

marvin3, marvin