You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WRITE currently supports block!, string! and binary! for its DATA. While this is enough for file scheme, other schemes can benefit from more types. For example writing OBJECT! or MAP! directly into database.
WRITE in R3 is supposed to be a low-level function, more similar to R2's WRITE-IO than its WRITE; same goes for READ and READ-IO. That is why there is no READ-IO and WRITE-IO in R3: they're READ and WRITE in R3. That is why the only types WRITE accepts are string, binary, and a dialect block to break the rules for higher level schemes. In the case you give above, that is a job for a dialect block.
It's just something to consider. Another thing to consider is: Why are you using WRITE here? There are plenty of port operations, most of which take a wide variety of datatypes. Not saying that it is a bad idea, it just doesn't fit the model very well. It's possible to make schemes that fit different models in R3. You don't have to use the READ/WRITE model for everything.
Rebolbot commented on Apr 1, 2013:
Submitted by:rebolek
Why am I using WRITE here? It may be supposed to be low-level but actually it's the easiest way to use the port! as I don't have to open it before taking action (WRITE does it for me). Of course it can be done in dialect but it can be done in WRITE directly to make the code simpler.
Rebolbot commented on Apr 2, 2013:
Submitted by:BrianH
So why aren't you implementing the scheme's behavior with a dialect block? Dialect blocks can do everything you want here, and they make the WRITE model more consistent between schemes, especially for lower-level schemes like TCP that can't possibly support other datatypes.
Rebolbot commented on Apr 3, 2013:
Submitted by:rebolek
Of course I can implement dialect on top of the scheme, it's just that WRITE url! DATA fits the key/value storage model perfectly, so it feels natural to use. I can add custom REDIS-WRITE that will do what I want, I just don't understand why when it can't be solved in WRITE directly.
I implemented this wish in this commit in my branch: Oldes/Rebol3@2433000
... and this is current function doc:
USAGE:
WRITE destination data
DESCRIPTION:
Writes to a file, URL, or port - auto-converts text strings.
WRITE is an action! value.
ARGUMENTS:
destination [port! file! url! block!]
data [any-type!] Data to write (non-binary converts to UTF-8).
REFINEMENTS:
/part Partial write a given number of units
length [number!]
/seek Write at a specific position
index [number!]
/append Write data at end of file
/allow Specifies protection attributes
access [block!]
/lines Write each value in a block as a separate line
The text was updated successfully, but these errors were encountered:
Submitted by: rebolek
WRITE currently supports block!, string! and binary! for its DATA. While this is enough for file scheme, other schemes can benefit from more types. For example writing OBJECT! or MAP! directly into database.
Imported from: CureCode [ Version: r3 master Type: Wish Platform: All Category: Unspecified Reproduce: Always Fixed-in:none ]
Imported from: metaeducation#2007
Comments:
Submitted by: BrianH
WRITE in R3 is supposed to be a low-level function, more similar to R2's WRITE-IO than its WRITE; same goes for READ and READ-IO. That is why there is no READ-IO and WRITE-IO in R3: they're READ and WRITE in R3. That is why the only types WRITE accepts are string, binary, and a dialect block to break the rules for higher level schemes. In the case you give above, that is a job for a dialect block.
It's just something to consider. Another thing to consider is: Why are you using WRITE here? There are plenty of port operations, most of which take a wide variety of datatypes. Not saying that it is a bad idea, it just doesn't fit the model very well. It's possible to make schemes that fit different models in R3. You don't have to use the READ/WRITE model for everything.
Submitted by: rebolek
Why am I using WRITE here? It may be supposed to be low-level but actually it's the easiest way to use the port! as I don't have to open it before taking action (WRITE does it for me). Of course it can be done in dialect but it can be done in WRITE directly to make the code simpler.
Submitted by: BrianH
So why aren't you implementing the scheme's behavior with a dialect block? Dialect blocks can do everything you want here, and they make the WRITE model more consistent between schemes, especially for lower-level schemes like TCP that can't possibly support other datatypes.
Submitted by: rebolek
Of course I can implement dialect on top of the scheme, it's just that WRITE url! DATA fits the key/value storage model perfectly, so it feels natural to use. I can add custom REDIS-WRITE that will do what I want, I just don't understand why when it can't be solved in WRITE directly.
I implemented this wish in this commit in my branch: Oldes/Rebol3@2433000
... and this is current function doc:
The text was updated successfully, but these errors were encountered: