🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.functional
1 messages
1 total messages Started by pop Fri, 01 Mar 1991 22:42
Functional Product
#816
Author: pop
Date: Fri, 01 Mar 1991 22:42
30 lines
2106 bytes
C, being a heteroousian language provides no defined way in which a
user can create code in a program and use it in the same program.
As Richard O'Keefe has pointed out, you can in fact do it by exploit
ing loopholes in the type-system of C, but in an entirely non-portable
way. In a functional language, when a function  returns a function as a
result, using some existing lambda expression or its equivalent, the
free variables of the lambda expression must be premanently bound to
the values they had at the time of call of the outer function (as in
the following Pop-11 (not an elegant syntax..)

define fp(f,g);           ;;; form product of functions f and g
  lvars f g;              ;;; declare f and g as lexical (UGH)
  procedure(x); f(g(x))   ;;; the inner lambda expression.
  endprocedure
enddefine;

the f and the g of the inner procedure (corresponding to a lambda
expression) are bound to the values they had at the call of fp. The
result is a NEW function, which binds the variables to this value and
then calls the body of the OLD lambda expression. One way of doing
this uses the technique used by POP-2 programmers and now called
 "lambda lifting" which gives extra parameters to the internal lambda
expression and then curries them in the fp function. With a
stack-based implementation, this provides an implementation mechanism
which is quite easy to do.

[In fact, the existing POP-11 implementation of function product
 written as concatenation  f<>g  does what Richard O'Keefe obviously
 did, and concatenates the code..., tho' of course other functionals
 would work as above].
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads