Giter Site home page Giter Site logo

palisades-lakes / dynamic-functions Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 177 KB

generic functions: more restricted but faster than Clojure multimethods

License: Apache License 2.0

Clojure 15.86% Shell 0.53% Batchfile 0.61% Java 83.00%
generic-functions clojure-multimethods clojure multimethods

dynamic-functions's Introduction

dynamic-functions

Clojars Project

This library is currently a vehicle for experimenting with design and implementation alternatives for generic functions (aka multimethods) in Clojure. It is therefore completely unstable (I'm committed to nothing for now) until at least version 0.1.0.

Initial ideas:

  • all functions are generic functions
  • trade flexibility of Clojure multimethods for performance
  • no hierarchies
  • dispatch on class-based signatures only
  • signature specified via arglist type hints
  • only simple arglists (no destructuring)
  • single method per arity equivalent to Clojure defn
  • high performance with hinted primitives in and out
  • Clojure functions are nearly opaque; the only API is `clojure.lang.IFn/invoke().
    Dynamic functions should be fully first class, with an API exposing, at a minimum:
    • the function name
    • any hints on the return value
    • the arglists, including type hints
    • the relevant parts of the lexical environment in which it was created, a list of bindings including names, values, and type hints, possibly other hints as well.
    • possibly also the dynamic environment
    • the expressions that defined the bodies
    • constructors that are functions, not just macros and special forms. For example, it should be possible to do something like
    (defn compose ^IFn [^IFn f ^IFn g]
      (assert (matches? (arglist f) (return-value g))
      (function (str (name f) "-o-" (name g)) (arglist g)
        `(f (g ~(arglist g)))))
    
    It should be possible to examine the returned function object, determine that it is the composition of f and g, and generate a new function by supplying a modified environment, say, by substituting something for 'f' or 'g'.

Usage

Dependency

Available from Clojars:

Maven:

<dependency>
  <groupId>palisades-lakes</groupId>
  <artifactId>dynamic-functions</artifactId>
  <version>0.0.x</version>
</dependency>

Leiningen/Boot:

Leiningen/Boot
[palisades-lakes/dynamic-functions "0.0.x"]

Code examples

(require `[palisades.lakes.dynafn.api :as df])

(df/defn intersects? [^IntegerInterval s0 ^java.util.Set s1] (.intersects s0 s1))

Acknowledgments

Yourkit

YourKit is kindly supporting open source projects with its full-featured Java Profiler.

YourKit, LLC is the creator of innovative and intelligent tools for profiling Java and .NET applications. Take a look at YourKit's leading software products:

dynamic-functions's People

Contributors

palisades-lakes avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.