Code Monkey home page Code Monkey logo

typed-cl's Introduction

Typed CL
--------

Typed CL is an extension to Common Lisp which allows for the typed
decleration of functions and variables.  Under the hood, it takes the
type information and writes the declerations for you, making your code
not only easier to read and safer (due to compiler type checks), but
it also gives the compiler more information for optimization and
(should) make your code run faster.

Some might say that dynamic typing is one of the best features of
Common Lisp.  The point of this project is twofold: during initial
writing and during editing/optimization.  You can hack with no types
and add them in later, or you can write them in during inital coding.
I find the syntax simpler and clearer than adding your own type
declerations by themselves.

Usage
-----

Typed CL comes with an asdf package that can be loaded or required as
needed.  I will look into adding it to quicklisp in the future.

Examples
--------

A simple example:

(def number square ((number x))
     (* x x))

def is exactly like defun except for including the return type and
function parameter types.  

A helper type 'list-of' is included to show how you can create
programmably verified types for your parameters:

(def integer sum (((list-of integer) l))
     (vars ((integer sum 0))
	   (dolist (n l)
     	     (setf sum (+ sum n)))
	   sum))

The above example also shows how to use the vars/vars* macros.  ldef
is the analog of labels with type information and follows the same
convention/syntax as def.

Essentially, adding type information just means to wrap your
parameters/variables with an extra set of parens, and put the type of
before the name and the default value after.

The real benefit is with safety > 0.  At least with SBCL it will give
plenty of warnings when the types do not match what is defined in the
signatures and declerations.

Care has been taken to provide decent warning/error messages on
invalid syntax but it's not perfect.  Sometimes the messages are a bit
hard to decipher.

--
Burton Samograd <[email protected]>

typed-cl's People

Contributors

burtonsamograd avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

busfactor1inc

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.