Quick Start

Getting started with slope programming is quick and easy. Follow the steps included on this page to get everything installed and take your first steps writing slope code.

Installation Prerequisits

Installation Options

Select the programs you wish to install and the shell commands to do the most common (global) install will appear in the following box. For other installation types please see the full documentation or the readme pages for each piece of software




git clone https://git.rawtext.club/slope-lang/slope
cd slope && make && sudo make install
cd ..

git clone https://git.rawtext.club/slope-lang/slp
cd slp && sudo make install
cd ..

git clone https://git.rawtext.club/slope-lang/slc
cd slc && sudo make install
cd ..
            
Building slope with GUI capabilities

There is a compile time flag to include the gui module. This is fully optional. It adds cross-platform gui options to slope. Instead of running the normal make command for slope you can run the following:


make gui && sudo make install
              

If you run into trouble building the gui it is likely due to the upstream dependency on fyne, so you may want to check out their pre-requisits. On FreeBSD, for example, it is known that you will first need to have pkgconf installed (sudo pkg install pkgconf).

Make a Simple Program

We are going to make a simple program to say either Hello, world! or Goodnight, world! based on a command line flag. We are going to accomplish this via the flag module.

Our first step is to download the flag module with slp (see below for installation isntructions without the package manager). Once that is done, you should be able to import it. So open a file in your favorite editor, lets call it: hello-goodnight.slo.


slp install flag
vim ./hello-goodnight.slo   # or any editor
            
Installing the flag module without slp

To get the flag package without installing slp you can run the following at your posix-ish terminal prompt:


git clone https://git.rawtext.club/sloum/flag
slope -install ./flag
              

Slope's -install flag will move a folder to the correct module location on your system.

Congratulations! You have just manually installed a module! You can do this for any other modules you may find if you prefer it to using slp. It is also useful for quickly testing out modules you are working on. Modules installed in this manner can still be listed and removed by slp if desired.

hello-goodnight.slo


;;; Hello/Goodnight
;;; A simpe hello world program that reads time of
;;; day from a flag given by the user

;; Load the flag module so we can use it
(load-mod flag) 

;; Write a function, or just enter global code,
;; to check for the flag "-night". In the case
;; below we are executing an annonymous lambda.
;; We could have just as easily stored it to a
;; variable with `define`, but for this purpose
;; anonymous seemed perfectly fine.
;;
;; Note that symbols in modules must be prefixed
;; by the module name and two colons.
;;
((lambda ()
  (if (flag::bool "-night")
      (display-lines "Goodnight, world!")
      (display-lines "Hello, world!"))))
            

Run the program


slope ./hello-goodnight.slo
# => Hello, world!

slope ./hello-goodnight.slo -night   
# => Goodnight, world!
            

It is, or course, possible to make this program without having to download a module. The sys-args constant represents an array of arguments, including the calling program (but not the slope interpreter itself), passed via the command line at run time. You could recursively loop through it to look for the flag in question. However, the point of this example is to illustrate a full workflow in which knowing how to use a module might be helpful.

Getting Help

Can't remember what a certain procedure does or what arguments it takes? Slope has a built in help system that allows a user to check the syntax of a particular procedure or get details on certain runtime constants. Accessing this system is easy and works for getting information about modules as well (assuming they were built with best practices in mind and provided a __USAGE variable).

The following is most easily viewed at the REPL. To run the REPL execute slope at your terminal prompt with no arguments. You should see a new prompt that will let you type in slope code and have it evaluated. This is a great way to use slope as a command shell, to test out ideas, or to write quick bits of code. What follows is a commented sample session at the slope REPL. Try running the commands (anything on a line that does not start with ;, which is a comment in slope) in your own REPL session to see what different procedures do!


;; Ask for information re: the usage of
;; the `begin` procedure
(usage begin)

;; Output:
;;
;; (begin [expression...]) => value
;;
;; Evaluates a series of expressions and returns the
;; value of the last expression that is evaluated

;; Get a list of procedures the system has usage for:
(usage)

;; Truncated output:
;;
;; append       apply        assoc        assoc?     
;; atom?        begin        begin0       bool?
;; car          cdr          ceil         chdir
;; chmod        close        cond         cons
;; ...

;; Get a list of procedures for a loaded module:
(load-mod flag)
(usage flag::)

;; Output:
;;
;; flag's Known Procedures:
;;
;; flag-bool
;; flag-is-set?
;; flag-number
;; flag-string

;; Get usage for a module procedure:
(usage flag::bool)

;; Output:
;;
;; (flag::bool [flag: string]) => bool
;;
;; Checks if a flag exists, but does not include flags
;; that have values passed with them
          

Thanks for trying out the Slope quick start!

That should be enough to get you started with the very basics. Slope is a fairly simple system with only a few types, which you mostly don't have to worry about. You should now know have the tools installed, have the knowledge necessary to write some very basic code and run it, and have the ability to look up basic information about the avialable procedures.

For more details and a deeper dive see the full language documentation.