[mercury-users] functions returning in values?

Ralph Becket rbeck at microsoft.com
Wed May 9 01:05:32 AEST 2001


> From: MCL [mailto:boris at aaron.ls.fi.upm.es]
> Sent: 08 May 2001 15:41
> >> An interesting application of this stuff is in cryptography: you
only
> >> have to describe the cipher function in Mercury and supply the
> >> appropriate modes and Mercury will give you both enciphering and
> >> deciphering, halving the likelihood of you introducing errors in
your
> >> code.
> 
>     I have to doubt it: any decent cryptography scheme should not be
> reversible that easy---unless you want to enumerate all possible clear
> messages.

Sorry, you misunderstand me.

You can write

:- pred cipher(key, plaintext, ciphertext).
:- mode cipher(in, in, out) is det.
:- mode cipher(in, out, in) is det.

cipher(K, P, C) :- ...

and get both directions from the same code, both of which of course
will require the key as an input.  I was not suggesting that you should
expect to get a key-cracker out of it.

I know other people who are interested in applying Mercury's mode system
to HW design (e.g. deriving both multiplexer and demultiplexer from the
same spec.)

- Ralph
--------------------------------------------------------------------------
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