HDTenEightyP/NetNews huggingface dataset:
From: olsson@ifi.uio.no (Jan Roland Olsson)
Subject: Run-Time Code Generation ?
Organization: Dept. of Informatics, University of Oslo, Norway
Date: Mon, 14 Dec 1992 15:27:15 GMT
Originator: olsson@hauken.ifi.uio.no


Functions that return other functions are common in
functional programs. The function returned is created
at run-time and is in strict languages most often 
represented using closures. 

In my view, a closure consists of 

1. A pointer to the machine code for a function.
2. One or more pointers to "arguments" of the function.
   These arguments may be other closures.

It sometimes happens that the function returned is
represented by 10 or more closures pointing to each
other. If the function is not recursive, these closures
normally form a tree that is isomorphic to the
expression tree for the right hand side of the
function definition.

A recursive function may be represented by closures 
that form a directed cyclic graph, where the cycle
can be introduced with a pointer i.e. a value of
ref type in ML.

I have a program in Standard ML of New Jersey that
synthesizes, i.e. writes, function definitions and
translates them to closures in order to execute them.

This works fine except for the fact that the resulting
functions execute about twice as slowly as functions
that are defined by ML source code and compiled.
Since the functions created at run-time are needed
over and over again, perhaps even millions of times
including recursive calls, this is a significant
performance problem for me.
Here is a small trivial example that illustrates
the problem.


fun compose 0 F = ( fn X => X )
  | compose N F = 
      let val g = compose (N-1) F
      in
       fn X => F ( g X )
      end;


val f1 = compose 5 tl;

val f2 = fn X => tl(tl(tl(tl(tl(X)))));


The functions f1 and f2 are the same, but calls
to f1 execute much slower than calls to f2.

What I really would like to have is a built-in
function 

compile : ( 'a -> 'b ) -> ( 'a -> 'b )

which has the same semantics as the identity 
function, but changes the representation of the
definition of its argument from lots of inter-
linked closures to pure machine code.
Since Standard ML of New Jersey stores machine
code on the heap as garbage collectable byte
sequences and since the compiler is part of a
running ML program this seems possible.

Am I the only ML programmer on this planet that
finds such a function useful ?

Or maybe there are some drawbacks or solutions that
I have overlooked ?

Or maybe I should use Common Lisp instead, which after
all has compile built in ? Needing to switch to
Lisp just for a performance problem like this would
really be a pity, since ML in my view is a much
better language and since Standard ML of New Jersey 
is an excellent implementation.









Newsgroups: comp.lang.functional
From: jones-mark@CS.YALE.EDU (Mark P. Jones)
Subject: Re: What is a monad?
Keywords: monads categories Haskell
Organization: Yale University, Department of Computer Science, New Haven, CT
Date: Wed, 16 Dec 1992 15:03:03 GMT

In article <1992Dec15.173324@aifh.ed.ac.uk> williamc@aifh.ed.ac.uk
(William Chesters) asks:

| What is a monad?

Well, since I'm responsible for starting the conversations about monads in
recent posts, I guess I'd better give you a reply!

The concept of a monad comes from category theory; I'll spare you the
full details since you can find these in standard text books on the
subject.  Much of the recent interest in monads in functional programming
is the result of a couple of papers written by Philip Wadler which show
how monads can be used to describe all kinds of different programming
language features -- for example, I/O, manipulation of state, continuations
and exceptions -- in a purely functional language like Haskell.

Here's a brief summary of how this looks in Haskell.  A monad is given by
a unary type constructor M and two operations:
    unitM :: a -> M a
    bindM :: M a -> (a -> M b) -> M b
One simple way to understand what is going on here is to think of M a as
a type of computations that return values of type a.  With this in mind,
an expression of the form  unitM e  behaves like a trivial computation which
just returns e.  An expression  m `bindM` f  represents a computation which
runs the computation m, takes the result and passes that as an argument
to f.  Every monad has unit and bind operators.  The thing that makes
individual monads more interesting is the additional structure that they
provide.  For example, the ability to update a state or to generate an
exception.

You'll find all of this is better explained in the papers that I mentioned
above:

 o Phil Wadler, Comprehending Monads (from the ACM conference on LISP &
   functional programming, Nice, France, 1990),

 o Phil Wadler, The Essence of Functional Programming (from ACM POPL 1992).

To try and explain how this relates to my earlier message, I'm currently
working with an extended form of overloading.  This doesn't really have
anything to do with monads, except that this approach to overloading turns
out to be particularly convenient for programming with monads.

The following definitions are a simplified version of the way that monads
(and functors) are defined in the prelude for my system.  If you are familiar
with the use of type classes in Haskell, you should be able to follow what
is going on here, except that whereas a type class corresponds to a set of
types, the following declarations correspond more closely to sets of type
constructors:

    class Functor f where
        map :: (a -> b) -> (f a -> f b)

    class Functor m => Monad m where
        return    :: a -> m a
        bind      :: m a -> (a -> m b) -> m b

(I happened to be using the name `unit' for something else, so I use the
name `return' here instead of `unit' as I did above (and as Phil does in
his papers)).

Hope this helps,
Mark
From: ark@alice.att.com (Andrew Koenig)
Newsgroups: comp.lang.functional
Subject: Re: Values escaping their type definition
Date: 17 Dec 92 15:28:53 GMT
Article-I.D.: alice.24432
Reply-To: ark@alice.UUCP ()
Organization: AT&T Bell Laboratories, Murray Hill NJ

In article <BzDIL1.B4I@cs.uiuc.edu> morrison@cs.uiuc.edu (Vance Morrison) writes:

> 	let 
> 	   datatype aType = constA | constB of int;
> 	in
> 	   constA
> 	end;

> This of course returns the value 'constA', in the outer scope, but
> in this scope there is no type for this value!!

More precisely, it returns a value that the compiler knows how to print
as constA, of a type which you have no way to name.  Why is that any
more disturbing from this?

	let
	   datatype aType = constA | constB of int
	   type aType = int
	in
	   constA
	end

Here you can mention constA but you can't write its type either, because
aType is hidden.

Incidentally, in both cases, aType, constA, and constB are out of scope
after the `end' and you can't use any of them.
-- 
				--Andrew Koenig
				  ark@europa.att.com
Newsgroups: comp.lang.functional
From: aspect@sun1g.informatik.Uni-Bremen.DE
Subject: Re: Is Miranda the one?
Organization: Universitaet Bremen
Distribution: comp
Date: Fri, 11 Dec 1992 17:11:28 GMT

In article <Bz39Dy.HIC@dcs.ed.ac.uk>, mikef@dcs.ed.ac.uk (Mike Fourman) writes:
|> In article <dt4.723949863@persimmon>, dt4@persimmon.ucsb.edu (David E. Goggin) writes:
|> 
|> > functional languages.  I am wondering whether everyone out there
|> > believers that Miranda is the BEST functional language?
|> 
|>       *********************
|> No,   ** ML is THE BEST. **
|>       *********************
|> 
|> Really, the question is ambiguous. If you want to develop an application in
|> a functional language, I believe ML provides the best available combination 
|> of rigorous language design and reliable, efficient compilers.

Really! Come on guys! Be serious now! There are several other languages (systems)
available being at least as good (rigorous,efficient,reliable,...) as this old
(nasty ;-) grandpa ML .... even (or especially) in scotland  ;-))))

|> 
|> If you want to teach lazy evaluation (for example) ML might not be your first
|> choice ;-)
|> 
|> -- 
|> Prof. Michael P. Fourman                     email        mikef@dcs.ed.ac.uk
|> Dept. of Computer Science                    'PHONE (+44) (0)31-650 5198 (sec)
|> JCMB, King's Buildings, Mayfield Road,              (+44) (0)31-650 5197
|> Edinburgh EH9 3JZ, Scotland, UK                 FAX (+44) (0)31 667 7209
|> -------------------------------------------------------------------------------



-- 
o  O O o           |  Joern von Holten
 \/|/\/  .         |    Uni Bremen
  //\   Let please |
Newsgroups: comp.lang.functional,comp.lang.scheme,comp.lang.lisp
From: nikhil@crl.dec.com (R.S. Nikhil)
Subject: Re: Spaghetti Stacks (reference)
Organization: DEC Cambridge Research Lab
Date: Tue, 15 Dec 1992 17:43:07 GMT

In article <BzB4Hw.1II@rice.edu>, sabry@datura.cs.rice.edu (Amr Sabry) writes:
> I have an incomplete reference to "Spaghetti Stacks":
> Bobrow & Wegbreit 1972 ....
> Does anybody have the complete reference.  Thanks.

@article{
    Bobrow73,
    key = "Bobrow, Daniel G.",
    author = "Bobrow, Daniel G. and Wegbreit, Ben",
    title = "A Model and Stack Implementation of Multiple Environments",
    journal = "Communications of the ACM",
    volume = 16,
    number = 10,
    year = 1973,
    month = "October",
    pages = "591-603"
}


Regards,

Rishiyur Nikhil (nikhil@crl.dec.com)
Newsgroups: comp.lang.functional
From: morrison@cs.uiuc.edu (Vance Morrison)
Subject: Values escaping their type definition
Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
Date: Wed, 16 Dec 1992 22:31:49 GMT


Hello,

I have just realized something about ML that I find rather odd and 
I am hoping to get some advice about consequences.

The oddity is that a value can escape the scope in which its type
definition was made.   Thus


	let 
	   datatype aType = constA | constB of int;
	in
	   constA
	end;


This of course returns the value 'constA', in the outer scope, but
in this scope there is no type for this value!!

I tried this SML of NJ and it accepted it and returned the message

		val it = constA : ?.aType
 
It seems to me that this can cause problem with the sematics of
the language and would be a problem in any language that allows
type definitions in inner scopes.  

Now my problem is that I don't know what the exact problems this 
could cause, and I was hoping that those who have had more experience
both defining and implementing ML could give their input.  

I have a copy of the Definition of ML, so if something there would
make this clear, please feel free to refer to it.

Vance


P.S.  :  I am also curious about a discussion about the problem
	 with arbitrary Type definitions in signatures.  Unfortuately
	 I did not save it.  If someone has the reference to the
	 relevant passage in the Definition Book I would love to
	 get that too.

 

Newsgroups: comp.lang.functional
From: williamc@aifh.ed.ac.uk (William Chesters)
Newsgroups: comp.lang.functional
Subject: What is a monad?
Date: 15 Dec 92 17:33:24 GMT
Reply-To: williamc@aifh.ed.ac.uk (William Chesters)
Organization: Dept of AI, University of Edinburgh, Scotland

(Sorry if this is a QFAQ).
I assume it has little or nothing to do with the philosophy of Leibniz.
-- 
"Computation. What's the problem?" (lecture notes I got given)
From: garyo@apricot.co.uk (Gary Osborne)
Newsgroups: comp.lang.functional
Subject: Orwell?
Date: 16 Dec 92 16:38:17 GMT
Organization: Apricot Computers Limited


Hi there,

I am interseted in the Orwell language, can anyone direct me to a copy that
runs on Unix (any) or DOS please. This will be used for non-profit-making 
research.

Cheers all,

Gary Osborne.


---------------------------------------------------------------------------
Internet: garyo@apricot.co.uk                 | Apricot Computers Limited
UUCP:     garyo@apricot.uucp                  | Research and Development 
Tel: +44 21 472 3002  Fax: +44 21 471 2935    | 90, Vincent Drive
                                              | Edgbaston
If all else fails from US, try:               | Birmingham.  B15 2SP
          apricot!garyo@relay.EU.net          | United Kingdom
---------------------------------------------------------------------------
Newsgroups: comp.lang.functional
From: piggy@hilbert.cc.utas.edu.au (La Monte Yarroll)
Subject: Re: The OBJ language
Organization: University of Tasmania, Australia.
Date: Wed, 16 Dec 1992 01:34:11 GMT

richmcdm@netcom.com (Richard McConnell) writes:

>I've recently read a paper which describes a language called OBJ, and I'm 
>wondering if anyone knows where I could go for more info.t
>    The paper is from 1988 ("Higher-Order Functions Considered
>Unnecessary for Higher-Order Programming" by Joseph A. Goguen, in the book 
>Research Topics in Functional Programming). I haven't found a trace of OBJ 
>OBJ in any newsgroups, "archie", etc., except a few bibliographic references
>to other papers written around the same time. The list of lots and lots of
>languages available on comp.lang.misc has no mention of it either.
>    If anyone could point me in the right direction, I'd appreciate it.

>Basil Hosmer	(richmcdm@netcom.com)

"If you have any questions about obtaining OBJ3, please call Judith
Burgess at (415) 859-5924 or contact us by email at
obj3dist@csl.sri.com.  For technical questions, please contact Mr.
Timothy Winkler at (415) 859-3192 or by email at obj3sys@csl.sri.com."

OBJ runs on top of AKCL.  You need licenses for both OBJ and KCL in
order to use it, but both of those licenses are free.  You can order a
full tape from SRI for US$150.
--
La Monte H. Yarroll	Home:		piggy@baqaqi.chi.il.us
   Work:		piggy@hilbert.maths.utas.edu.au
   AKA:			piggy@gargoyle.uchicago.edu
   Once upon a time:	postmaster@clout.chi.il.us
From: johnw@syma.sussex.ac.uk (John Williams)
Subject: Re: Syntax Misdesign
Organization: University of Sussex at Brighton
Date: Mon, 14 Dec 1992 18:14:45 GMT

sfk@otter.hpl.hp.com (Steve Knight) writes:
> The number of beginners who want to build a list of one element with the
> result of a computation, say ``f(x)'', in it who write
>     [ f(x) ]
> must be beyond recall.  In fact, I suspect _every_ programmer made this
> eminently sensible guess when they were learning to program in POP and
> discovered, to their horror, just how wrong they were.

Only those programmers who had the misfortune to learn another
language first!. I don't think there's anything intrinsically
counter-intuitive about the fact that the list and
vector syntax doesn't evaluate items by default.

John
From: pop@cs.umass.edu ( Robin Popplestone )
Newsgroups: comp.lang.pop
Subject: Associativity and stacks
Keywords: associative stack constructor
Date: 15 Dec 92 14:14:48 GMT
Organization: University of Massachusetts, Amherst
Originator: pop@roo.cs.umass.edu

Aaron suggested I was being a little cryptic (death watch beetle?) in what
I said about stacks and associativity. Well, lets try to expand a little.

A constructor function, being an operation of a free algebra, is
non-associative. This means that our favourite mapping functions (e.g.
maplist) are homomorphisms of free algebras determined therefore entirely
by operations on the generators. However some important computational
constructs (e.g. program source text) are semigroups under some operation
(e.g. concatenation). If you are going to serialise a structure (e.g. a
when you translate a thought into a sentence that you utter) you typically
need to map into such a semigroup. And the stack provides just the right
mechanism.  E.g. a procedure to translate an applicative structure to the
source for a language L might have the form in POP-11

    translate_to_L(functor(E)), translate_to_L(arg(E))

where each call pushes source code on the stack.

Robin.
From: ianr@syma.sussex.ac.uk (Ian Rogers)
Subject: memoise
Organization: University of Sussex at Brighton
Date: Tue, 15 Dec 1992 15:54:27 GMT

[I don't remember RobinP's address, so I'll have to go public %-]

Robin, could you post your Pop11 procedure memoise utility to the net please?

Ta,

Ian
Newsgroups: comp.lang.pop
From: andyh@syma.sussex.ac.uk (Andy Holyer)
Subject: Re: Editors
Organization: University of Sussex
Date: Wed, 16 Dec 1992 10:52:27 GMT

In article <116670034@otter.hpl.hp.com> sfk@otter.hpl.hp.com (Steve Knight) writes:
>> So what is your over all conclusion Robin? Perhaps oneof():
>> 1) Ved should be extended to offer more of the functionality of EMACS.
>> 2) Pop11 should be separated from the editor, to allow full user choice.
>
>Surely (2) should refer to POPLOG and not POP-11?  I don't see how POP-11
>and VED are connected in any interesting way (unless you count the fact
>that VED is largely written in POP-11.)
>
Good point. To turn the problem on its head for a bit, something I'd like
to see is the converse - a (cut down) version of xved which contains no
Poplog functionality :-) OK, so that's not actually possible, I accept,
but I'm not *totally* off my trolly, I'll explain: since I use xved as
my editing interface much of the time, I often use ved or xved as the
screen editor for other programs (I'm doing so now, as it happens).
However, as is currently instantiated there are two problems with this
arrangement: 1) ved takes ages to start up (a problem shared by emacs,
btw), and 2) On my SPARCStation, there often isn't the memory for more
than one ved to run at once (or at least for more than one xved). Hence
you get mailers etc. barfing because there isn't enough free memory to
run the editor, and I gat all cross and send people rude messages :-)

Were the "separation of church and state" :-) discussed above
instituted, then many of these problems would disappear - and Pop as a
whole would IMHo be made much more flexible.

Of course it would be even nicer if these "mothership" applications
could be taught to just send a message to a server saying "give me an
xved window" instead of just merrily running a new editor, but that's a
unix issue....


-Andy
-- 
&ndy Holyer, School of Cognitive and     |Due to recent events in the USA,
Computing Studies, University of Sussex, |I find I can no longer use this
JANET: andyh@cogs.sussex.ac.uk           |.sig quote. Normal service will
                                         |be resumed when I find another one.
From: kers@hplb.hpl.hp.com (Chris Dollin)
Date: Wed, 16 Dec 1992 16:27:24 GMT
Subject: Re: Syntax Misdesign
Organization: Hewlett-Packard Laboratories, Bristol, UK.
From: bh@anarres.CS.Berkeley.EDU (Brian Harvey)
Newsgroups: comp.lang.pop
Subject: Re: List and Vector Syntax (long)
Date: 16 Dec 1992 23:28:32 GMT
Organization: University of California, Berkeley
NNTP-Posting-Host: anarres.cs.berkeley.edu

I'm a non-Pop-programmer following this discussion with interest.
If I'm understanding right, it's proposed that the notation
	"strawberry fields forever"
should mean three separate quoted words.

Is there a way to include a space character in a word?  This looks
like a potential ambiguity to me.  In Lisp we'd say

	'(strawberry fields forever)			3 words
	"strawberry fields forever"			1 string

to distinguish these cases.
From: tmr@cs.bham.ac.uk (Tim Read)
Newsgroups: comp.lang.pop
Subject: rc_graphic
Date: 12 Dec 92 12:37:52 GMT
Organization: School of Computer Science, University of Birmingham, UK

Using LIB * RC_GRAPHIC I wish to tile my window (created with rc_start) with
a bitmap. I have tried doing:

XpwLoadPixmap(rc_window,'./gray1.xbm',-1,-1,0) -> pixmap_data;

But this does not change anything. I checked that pixmap_data was not false.
I must be missing something very obvious here. Is there some function I have
to use with the returned pixmap_data? I tried using XtSetValues but got very
stuck. 

Any suggestions would be gratefully accepted :-)

 Tim
--
    --------------------------------------------------------------------
    Tim Read, Email: tmr@cs.bham.ac.uk, The Attention and Affect Project
    Room LG23, School of Computer Science, The University of Birmingham,
    B15 2TT, England, Phone: +44-(0)21-414-4766, Fax: +44-(0)21-414-4281
    --------------------------------------------------------------------
From: sfk@otter.hpl.hp.com (Steve Knight)
Date: Tue, 15 Dec 1992 13:40:58 GMT
Subject: Re: Editors
Organization: Hewlett-Packard Laboratories, Bristol, UK.
Newsgroups: comp.lang.pop

> So what is your over all conclusion Robin? Perhaps oneof():
> 1) Ved should be extended to offer more of the functionality of EMACS.
> 2) Pop11 should be separated from the editor, to allow full user choice.

Surely (2) should refer to POPLOG and not POP-11?  I don't see how POP-11
and VED are connected in any interesting way (unless you count the fact
that VED is largely written in POP-11.)

My own conclusion would be (3), POPLOG should be extended to provide more
standard tools, such as mailers and readers, but this extension should NOT
be done using VED but using the X-toolkit interface.  It is completely
unacceptable to me to use a text editor to process my mail.  I want a 
graphical interface properly geared up for the task in hand.  Otherwise
you end up with the lame EMACS compromise and no one wants that!

[The problem with this suggestion is that the actual toolkit to be
used is unclear.  Should it be Motif or OpenLook?  Or even Athena (yukk)?
Another possibility would be to write a POPLOG-style toolkit based
solely on X-windows and not the X-toolkit (but how to integrate into the
event handler?)  Yet another solution would be to extend the Poplog widget
set to provide enough widgets for this.]

However, I do agree with Tim in his suggestion that POPLOG should be
made to work nicely with EMACS.  And that probably means making sure that
extend_searchlist is able to broadcast to the user-editor that the search
lists have changed.

Steve
From: tmr@cs.bham.ac.uk (Tim Read)
Newsgroups: comp.lang.pop
Subject: Re: Editors
Date: 14 Dec 92 15:58:21 GMT
Organization: School of Computer Science, University of Birmingham, UK

>>>>> On 11 Dec 92 21:03:47 GMT, pop@cs.umass.edu ( Robin Popplestone ) said:
> I must confess to using Ved for almost everything, even having hitched it
> up to viewers for .dvi, .ps and .o files. In general computationally
> literate culture (as opposed to computer science types) it would appear to
> be evolving as more consistent with how most people actually use computers
> than is EMACS, and thus arguably a more general purpose ASCII editor.

> There are certain architectural features of EMACS one does like however.
> The interpretation of commands via the neat argument descriptors for
> functions is better than VED's ad-hoc vedargument stuff. The modes (like
> them or not - often I feel imprisoned by modes) are an interesting
> application of the shallow binding of variables (i.e. the simple
> forms of dlocal in POP-11). Since shallow binding is usually regarded as a
> BAD THING by theorists, one finds its use in EMACS interesting.
> (Essentially an EMACS buffer has a set of shallow-bound variables which are
> related to the mode, whereas VED in fact has a fixed set of shallow-bound
> variables for each buffer).

> It would be nice to find a POP-11 program which summarised one's mail file.

So what is your over all conclusion Robin? Perhaps oneof():

1) Ved should be extended to offer more of the functionality of EMACS.
2) Pop11 should be separated from the editor, to allow full user choice.

I'm for 2.

 Tim

--
    --------------------------------------------------------------------
    Tim Read, Email: tmr@cs.bham.ac.uk, The Attention and Affect Project
    Room LG23, School of Computer Science, The University of Birmingham,
    B15 2TT, England, Phone: +44-(0)21-414-4766, Fax: +44-(0)21-414-4281
    --------------------------------------------------------------------
Newsgroups: comp.lang.pop