[mercury-users] Locally defined procedures in Mercury

brogoff brogoff at speakeasy.net
Thu Jun 9 06:35:23 AEST 2005


> > Ralph Becket, Sunday, 5 June 2005:
> > Gregory D. Weber, Saturday, 4 June 2005:
> > Is it possible to define a recursive procedure within another
> > procedure, similar to Scheme's letrec or CommonLisp's labels?
>
> The short answer is "no". We have discussed adding named local
> preds/funcs to Mercury, but it's not trivial to implement and to
> date we haven't found writing separate preds/funcs (i.e. non-local
> ones) to be that much hassle.
>
> -- Ralph

Hi, I'm just starting with Mercury, coming from OCaml, and this is
a bit surprising to me. I use nested functions throughout my OCaml
code, and block structure is something I take for granted in high
level languages. It's even one of the reasons I like Ada and kin
better than C and it's kin. If you fully utilize that style, the local
functions are a bit simpler than if you yank them out, since they
can refer to surrounding constants without passing them as arguments.
Also, it's cleaner to reuse names like loop or iter.

Looking now at the docs, especially the comparison with Haskell, I guess
I shouldn't have been surprised. Is there a document where this decision
is discussed in greater depth?

Perhaps I'll change my mind with more Mercury experience, but I think
it's something worth considering (even if nontrivial to implement), if
you wish to support the functional style fully.

-- Brian
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list