Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Bill Wood <william.wood3@comcast.net>
To: Oliver Bandel <oliver@first.in-berlin.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] From a recursive circuit to a functional/recursive OCaml-code...
Date: Sat, 04 Feb 2006 23:55:51 -0600	[thread overview]
Message-ID: <1139118951.18593.20.camel@localhost> (raw)
In-Reply-To: <20060205041600.GA5936@first.in-berlin.de>

On Sun, 2006-02-05 at 05:16 +0100, Oliver Bandel wrote:
   . . .
> Is it necessary to have state-variables in a record?
> Is it then (with records) functional implementation?!

If I understand your problem correctly, you're looking for a way to
model a synchronous dataflow network in OCaml.  To do this, I think you
need a global state to capture the simultaneous presence of data tokens
on each input of each function in your network.

The record mentioned above could contain a field for each input line; at
the next tick of the clock the functions are applied to their inputs,
and their outputs then fill in fields of the record corresponding to the
next set of inputs.  The dataflow aspect then manifests as the necessity
to get new values from the "x" input line, for there's no other way to
set that field in the next record.

This approach brings into sharp focus the initialization problem --
initially, there are no inputs on the "e" inputs to either block "A" or
"B".  Thus you have to specify how a block fires with one or more
undefined inputs.  You might model this by defining the type of data
running around the system to be something like "mydata option", and then
define how the various functions act when one or more inputs are "None".
Finally, the initial state record would have "None" in each field
corresponding to "no input available".
   . . .
> But I'm not clear about how to write this function "f",
> because it needs mutual recursion...
> In a purely impeative way I think i woulf find a solution,
> but thinking about it in Ocaml => blackout. ;-(

By using the state record you avoid having to write the block functions
as direct mutual recursions; instead, all the functions take the state
record as input and together (along with the input stream) define the
next state record.
   . . .
> and inside "f" there also is a feedback.

This approach takes care of the feedback at the expense of having to
model each block as operating with one or more inputs latched low, say,
until upstream functions finally supply data.

 -- Bill Wood



  parent reply	other threads:[~2006-02-05  5:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-04 21:19 Oliver Bandel
2006-02-05  2:29 ` [Caml-list] " skaller
2006-02-05  4:16   ` Oliver Bandel
2006-02-05  5:42     ` skaller
2006-02-05 14:17       ` Oliver Bandel
2006-02-05 16:05         ` skaller
2006-02-05 18:07           ` Oliver Bandel
2006-02-06 11:52       ` Oliver Bandel
2006-02-06 13:10         ` Oliver Bandel
2006-02-05  5:55     ` Bill Wood [this message]
2006-02-05 11:26       ` [Caml-list] From a recursive circuit to a functional/recursiveOCaml-code Frédéric Gava
     [not found]     ` <1139134445.28935.14.camel@localhost>
     [not found]       ` <20060205175014.GA1969@first.in-berlin.de>
     [not found]         ` <1139178136.463.37.camel@localhost>
2006-02-05 23:23           ` [Caml-list] From a recursive circuit to a functional/recursive OCaml-code Oliver Bandel
2006-02-05 23:46             ` Oliver Bandel
2006-02-06  3:39             ` skaller
2006-02-05 11:45 ` Oliver Bandel
2006-02-05 18:19 ` Oliver Bandel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1139118951.18593.20.camel@localhost \
    --to=william.wood3@comcast.net \
    --cc=caml-list@inria.fr \
    --cc=oliver@first.in-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox