Code Monkey home page Code Monkey logo

dispatch.m's Issues

Example does not run as advised: probably need to get rid of weak typing in `ismethod`

>> foo(true,2)
Index exceeds the number of array elements (1).

Error in dispatch>isa_ (line 73)
        varisa(i) = isa2(var{i},type{i});

Error in dispatch>ismethod (line 42)
        out = isa_(var, numOrType);

Error in dispatch (line 24)
        if ismethod(var, methodTable{i,2})

Error in foo (line 3)
    out = dispatch(varargin,...

Though it works if I remove the dispatch to the "Person" class in the methodTable. I believe this happens because of the effective weak-typed use of numOrType in ismethod.

On a side note I think you probably could enable multiple outputs by just making use of varargout and collecting from the specialized implementation everything as [varargout{1:nargout}]. This was the initial patch I was targeting, but the fundamental design issue (in my view) with collision between dispatch on number of (numeric-only) and on non-numeric types has made me desist. Nevertheless I find the idea of building an "julia-like" ergonomic interface for multiple dispatch via isa quite interesting, I might return on this when I have time: matlab has all the needed functionality for that, just a painful API. Thanks for the idea :)

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.