Coder Social home page Coder Social logo

polymorph.stl's Introduction

Polymorph Standard Library

Inspired by generic-cl and specialization-store, this library provides support for overloading common simple functions (in many other languages usually referred to as "operators") based on types. Supports user defined specializations as well. It also tries to be as strictly typed as possible, resulting in compile-time errors/warnings in case types are mismatched. However, there are ways to relax the restrictions in places where it would make sense (such as different numeric types comparison).

It may look like the whole thing consists of too many systems that are too small, but that is intentional. The main idea is, even if some users disagree with the overall design, they can still use small parts. It is also easier to debug and maintain several small systems rather than a single big one.

Implementations support

It currently works anywhere adhoc polymorphic functions work. Cltl2 support is the most important thing.

Overview

Systems

Maths

Ad hoc polymorphic:

  • +,-, *, / are arithmetic operators
  • =, /= are equality operators
  • >,>=, <,<= are inequality operators

Parametric polymorphic:

  • min and max are based on < and > (currently any kind of parametric polymorphism is just a convention).

Copy-cast

Ad hoc polymorphic:

  • cast function is similar to coerce.
  • copy currently has two versions: deep-copy and shallow-copy

Warning, these will probably be refactored to have ad-hoc copy and parametric deep/shallow versions.

Access

Accessors to different properties.

Ad hoc polymorphic:

  • at function is an extended version of elt.
  • front/back are the first and last elements of the container whenever that makes sense. Are SETFable.
  • emptyp,size, capacity deal with container sizes.

Macros

While there are currently no "polymorphic" macros, these macros are useful for the style of development this system suggests.

  • zapf is for updating values value in place using its previous value. It is a generalization of macros like incf or decf.
  • bind* unites 3 things: let*, multiple-value-bind, and builtin type declarations. Uses default for filling out the values if type was provided, otherwise defaults to nil.
  • define-struct is a simplification of defstruct that fills in default values using default and given types. It has accessors for slots defined via defpolymorph and is able to do simple inheritance. Very much alpha version, the name may change.

Utility

Utility functions, may or may not be exported at all.

  • default returns a reasonable default object for a given type.
  • ind is an index type.

Data structures

WIP. Will have at least maps (RB tree based), deques (array based) and double linked lists.

polymorph.stl's People

Contributors

alex-gutev avatar commander-trashdin avatar mtreis86 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.