Coder Social home page Coder Social logo

boa's Introduction

Boa

Boa is a stack-based programming language alternative to Python.

Usage

Pushing items onto the stack:

10
"string

Setting variables:

10# push 10 onto the stack
number# pop an item from the stack and set the number variable to the item

Getting variables:

number# since number is now defined, push the value of number onto the stack

Calling functions:

#push an argument
"Hello World!
1# push the number of arguments
print# push the function object. Note that builtins are predefined variables and cannot be overwritten.
!# call the function object. Pops the function object, number of arguments, and *number of arguments* more items off the stack, and pushes return value onto stack
:o# silently drop the last item of the stack (return value from print, which is None). Not necessary at the end of a program, but is good practice.

Calling functions can also be used to push instances of other Python classes onto the stack:

4#push 2nd argument
3#push 1st argument
2# push number of arguments
complex# push class object
!# pop complex and 2 off the stack and call ClassName() with 2 arguments (i.e. create an instance of complex(3, 4)) and push the result onto the stack
num# store (3+4j) in "num"
num# push back onto stack
1# push number of arguments
print# push function
!# call and push ret to stack
:o# drop None
num# push onto stack again
1# push number of arguments
abs# push function
!# call and push ret (5) to stack
1# push number of arguments
print# push function
!# call and push ret (None) to stack
:o# drop None

boa's People

Contributors

kenny2github avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.