[CCC DEV] Concerning commit 6894(ish)

Matt Jadud jadudm at gmail.com
Tue Jul 20 00:56:01 BST 2010


Ah.

On Mon, Jul 19, 2010 at 7:02 PM, Michael Pirrone-Brusse
<pirronm at allegheny.edu> wrote:
>   BYTE aByte:
>   SEQ
>     analogReference (INTERNAL)
>     aByte := analogRead (board.pin)

Would your code end up looking like this?

BYTE FUNCTION analogRead(VAL INT pin)
  INT reading.value:
  VALOF
    SEQ
      ... do read via some call to something written previously...
    RESULT reading.value

I can't remember, but I thought we had an ADC PROC that took a
variable and set it, which we then wrapped in a process-oriented
interface. You would use that in the FUNCTION you're writing.

Does that make sense? You can write functions, but you can't modify
state (as Fred said). Or, you can write it as a PROC:

PROC analogRead(VAL INT pin, RESULT INT reading.value)
  ... do stuff...
  reading.value := ...
:

A PROC can mutate a reference passed as variable, but not as a VAL.
RESULT hints to the compiler that your intent is to modify that
variable from within the PROC.

Does any of that help?

Cheers,
Matt




More information about the developers mailing list