Sage-Code Laboratory

Bee Standard Library

Bee is a compiled language. That means you must include whatever you use in your code. We will design a small standard library to be included with any program, that will give a small footprint to any Bee executable.

Standard Library

Standard library contains:

Data rules

Introspection Rules

rule Purpose
type type name
size type size

Bee Type System

Primitive types and composite types are all included automaticly in the standard library. So you do not have to import any of it to use them in your algorithms. This will make basic runtime quite large but we hope it worth it to avoid all these imports.

Composite Types

rule Purpose
length type length
capacity type capacity
min type minim limit
max type maxim limit

List & strings Type

rule Purpose
split Split a string into a list / array
join Join a list into a string
find Search one sub-string in a string
replace Replace one sub-string in a string
trim Remove blank spaces from string
right Align string to right by adding spaces
left Align string to left by adding spaces
center Align string to center by adding spaces

Numeric Type

rule Purpose
round Convert one real into an integer
floor Convert one real into an integer
parse Convert one string into one number
random Create random numbers

Date Time

Modules for date and time will contain all required rules.


rule Purpose
now get current time


rule Purpose
now get current date

Error Type

Bee has pre-define Error objects with codes in range (1..200):

** global type
type Error: {code ∈ Z, message ∈ S} <: Object;
** exception objects
$zero_division  := {100,"division by zero"}     ∈ Error;
$null_reference := {101,"null reference usage"} ∈ Error;
$value_overflow := {102,"value overflow"}       ∈ Error;
$out_of_range   := {103,"value out of range"}   ∈ Error;
$type_mismatch  := {104,"data type mismatch"}   ∈ Error;
$user_error     := {200,"user defined error"}   ∈ Error;
** Standard error
$standard_error  := {1,"standard error"}    ∈ Error;
$unexpected_error:= {2,"unexpected error"}  ∈ Error;

Mathematic Rules

Math library will implement extra rules that are not available until you import "math" library. These are functions you rarely use and require extra memory space to be available in your program.

rule Purpose
sin sinus
cos cousin
tan tangent
pow power
sqr square root
fac factorial
mod module rule y := |x|

System Library

Interaction with operating system require load from library.

  |-- system
  |     |-- io.bee
  |-- db

File IO

To read and print into files and save to disk, we must use library. This library define type "F" : file handler. It offer support for file input/output.


Next is a fragment from library that define rules open and close.

rule .open(name ∈ S, mode ∈ A) => (file ∈ File);
rule .close(file ∈ File);
rule .list(folder ∈ Folder) ∈ (S);
rule .exist(name ∈ S) ∈ L;
rule ,delete(name ∈ S); 
rule ,rename(name, new_name ∈ S); 

remember: public rules start with dot: "."

File IO

System IO rules

rule Purpose
open Open a file
close Close a file
exist Check if file or folder exist on disk
list Read a list of files and folders from directory
tree Read tree of directory in memory
delete Remove a file / directory
rename Make a new directory

Two data types must be available: File, Folder

File rules

Folder rules

Making files/folders

make file_name   :='name','w');
make folder_name :='name');

Go back to: Bee Index