Following up on some posts from the "Symbols explicit" thread, where there were some questions about concrete use cases.
To be honest, I'm not sure how clear this is going to be, because the best way to make it clear is to build it in Pd, and I don't have time to do something complicated.
Anyway... consider a "data stream" interface. Some part of the code asks the stream for the next value, and -- in text languages -- the value is returned to the caller. There may be dozens of places that need to access the stream, and the rule is, whoever asked gets the result.
I had mentioned parsing. If the input string is held in a stream wrapper (in SC, CollStream
), then this object can be passed around the system as a function/method argument, and everywhere that needs the next character can just ask for it.
The challenge, then, in graphical patchers is that there is no concept of returning a value to the caller. A message traversing a patch cable is calling into the next object. "Returning from a function" is, in patching terms, backtracking to a prior object to see if it has more output cables that haven't been handled yet. But data don't travel backward up the stack, only down.
A file handle can be treated as a stream. Here, Pd recognizes the issue and allows shared file handles to be "define"-d: [file define xyz], and then every "caller" can have its own [file handle xyz].
If the data source is in memory, though, then the current position in the stream has to be maintained within the abstraction -- and there can be only one of those, because Pd/Max don't have a concept of a pointer to an abstraction that's loaded somewhere else. E.g., a really simple data queue (didn't implement "rewind" here) -- as an abstraction, everything would have to go through this.
So then there has to be a way to request a value from a specific part of the patch and get back to that part of the patch.
... where oid said, "In that situation I would say that [pd my-stateful-thing] should have a send method" -- seems to me that's what the above is (just not folded into the subpatch).
Regarding your live-coding dialect, would be curious to see it if you shared it anywhere.
https://github.com/jamshark70/ddwChucklib-livecode -- see https://github.com/jamshark70/ddwChucklib-livecode/blob/master/cl-manual.pdf for full documentation.
The parser (with heavy use of CollStream throughout) is at https://github.com/jamshark70/ddwChucklib-livecode/blob/master/parsenodes.sc
Example:
Most of what I do in pd is designing languages
Quite curious about that. Anything public to see?
hjh