• 1 Post
  • 2 Comments
Joined 1 year ago
cake
Cake day: November 19th, 2023

help-circle

  • Besides the concept distinction, there is a purely practical concern in that you want apply to be available as a callable function in instances where you have a list of values you wish to supply as arguments to a function. i.e. Ordinary function calls have the form (function arg1 arg2...), but in some cases the values arg1/arg2/… aren’t bound to symbols(or there could be an arbitrary number of them not known at compile time) but are the elements of a list args, so you can write (apply 'function args).


  • Why not just store data and have a procedure which executes with that data as an argument? That’s completely equivalent to what you’re asking for. I don’t imagine there are any libraries that support storing lambda structures in postgres or any other database, because it doesn’t make a lot of sense to do so (lambdas could require arbitrary amounts of closure data to be saved, and are very implementation dependent).

    It’s certainly possible, but you should probably be rethinking exactly what you want to do; one thing you might end up doing is writing a sort of store-procedure function which stores the data necessary for a retrieve-procedure function to create the lambda on demand.

    Maybe I’m misunderstanding what you mean by stored procedure and you just want to call a postgres procedure defined with ‘create procedure…’ . I think you could do that with postmodern and simply the name of the procedure as a keyword, i.e.

    > (sql (:my-proc 1 2))
    "my_proc(1, 2)"