Giter Site home page Giter Site logo

Nested DEFUNs are bad about loving-common-lisp HOT 3 CLOSED

lispm avatar lispm commented on September 9, 2024
Nested DEFUNs are bad

from loving-common-lisp.

Comments (3)

whitten avatar whitten commented on September 9, 2024

So I'm an admitted newbie here, but it seems if you had a function that you were memo-izing
(where you checked the values of argument and returned a pre-computed result) then one way of doing this would involve redefining the global function each time it is used to "hard bake" the calculated value already. This seems efficient in time, if definitely not in space.

Or am I missing some crucial insight ?

from loving-common-lisp.

lispm avatar lispm commented on September 9, 2024

Why would you want to do that? If the function retrieves a value from a variable, you don't need to redefine the function. If you put the value as data into the function, then it would make even less sense.

Doubly nested DEFUNs are in Lisp not used. I've never seen it used. DEFUN is for defining top-level functions at the top-level. FLET and LABELS is for defining local lexical functions.

Singly nested DEFUNs inside LETs for closures are also a bad style. Creating global closures at load time is not that great as a tool.

from loving-common-lisp.

mark-watson avatar mark-watson commented on September 9, 2024

Thanks lispm, that is a valid point. It is an old habit of mine in both Scheme and Common Lisp to "hide" local functions inside the function that uses them.

from loving-common-lisp.

Related Issues (8)

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.