🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2548

Re: Look, Ma, I can dynamically compose functions in C!

#2548
From: Dan Bernstein
Date: Wed, 26 Dec 1990 14:38
43 lines
2505 bytes
In article <19390@yunexus.YorkU.CA> oz@yunexus.yorku.ca (Ozan Yigit) writes:
> In article <19468:Dec2100:23:0790@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu
> (Dan Bernstein) writes:
> >Of course, a more complete implementation would manage struct fun
> >storage, possibly with garbage collection.
> Yep. A more complete implementation would effectively be an interpreter
> that can handle arbitrary-depth function composition.

The version I posted can handle arbitrary-depth function composition
with the same syntax and reasonable efficiency. It just requires the
user to keep storage for the functions.

> This must be what
> you mean when you talk about real-world programming. Sigh.

Yes. If I ever need to compose functions in a real-world program, I will
use a solution along the lines that I posted. What are you complaining
about?

A few people have said that I'm cheating in some sense, though they
can't explain exactly how. Let me draw an analogy.

In my growing Q language, every syntactic construct eventually gets
converted into what looks like a function call. A function declaration,
for example, is converted into fundecl(fun,result,args), with the
appropriate types filled in.

fundecl is by default defined as defaultfundecl, which has a fixed
meaning---but it can be redefined as something else. You can turn every
function declaration into one of those struct funs if you want. It's all
done syntactically, and it's completely invisible to the rest of the
program.

Now answer this: Does Q have composable functions? Just as in C, the
``functions'' as defined by the language cannot be composed. But you can
change the syntax so that, just as in C++, a previously normal function
turns into something you can compose.

I think there's a big difference between the semantics---the power---of
a language and the syntax. Behind its syntactic veil, C++ does have
composable functions. So does Q. And so does C.

---Dan
Technical Details
Message-ID: <21126:Dec2614:38:2890@kramden.acf.nyu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!tut.cis.ohio-state.edu!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd
References: <1990Dec19.222059.6878@mathrt0.math.chalmers.se> <19468:Dec2100:23:0790@kramden.acf.nyu.edu> <19390@yunexus.YorkU.CA>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!att!tut.cis.ohio-state.edu!hsdndev!cmcl2!kramden.acf.nyu.edu!brnstnd
From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein)
Newsgroups: comp.lang.misc
Subject: Re: Look, Ma, I can dynamically compose functions in C!
Message-ID: <21126:Dec2614:38:2890@kramden.acf.nyu.edu>
Date: 26 Dec 90 14:38:28 GMT
References: <1990Dec19.222059.6878@mathrt0.math.chalmers.se> <19468:Dec2100:23:0790@kramden.acf.nyu.edu> <19390@yunexus.YorkU.CA>
Organization: IR
Lines: 43