[EMAIL PROTECTED] wrote:
> pekr:
> > hmm, I am not sure it's good. I am not sure above solution is
> abstracted enough. I wouldn't mess read/write functions with
> "proprietary" refinements.
>
> read/object %MyZipFile.zip Zip!/read
> write/object %MyZipFile.zip [...] Zip!/write
> etc...
>
> read/object %"MyCustomCompression or similar.xyz"
> CustomCompression!/read
> read/object %MyGifPicture.gif GIF!/read
> write/object %MyGifPicture.gif PictureData GIF!/read
> etc...
And still I think different aproach is needed, a datatypes one. Look at:
>> source parse-xml
parse-xml: func [
"Parses XML code and returns a tree of blocks."
code [string!] "XML code to parse"
][xml-language/parse-xml code
]
>>
1) we already have read/binary
2) we are talking about "loading" more than "reading" the things....
<FANTASY>
%User.r
----------------
......
foreach file read %datatypes/ [install-datatype] ; system/datatypes
foreach file read %storage/ [install-storage] ; system/storage
--- end of user.r
above code could create two system objects (or just fill in existing
ones) with block of datatypes, installing it into some thought of
categories (as we have with scripts posted on rebol.org e.g.)
system/datatypes/picture, system/datatypes/sound, etc. The hierarchy is
needed for cerating types of operation making sense to appropriate
format.
e.g.:
bmp!: make root-picture []
wav!: make root-sound []
jpeg!: make root-anim []
above could install some global datatype functions for appropriate
category (look at nntp.r, it is similar: news: make root-protocol
[....])
bmp?
wav?
jpeg? ; all inside of object, determining, if data is of appropriate
type?
either not bmp? %my-picture [print "Heiya, not a bitmap, I am sorry
..."] [
pict-obj: bmp/load %my-picture
jpg/save pict-obj/raw-data
; load would just fill in pict-obj/raw-data field with some bitmap
format, while jpeg/save would save to native jpg format.
; Of course, the aproach would have been more complex, eg. handling of
colors, compression etc.
; e.g. some-pict: make jpg! []
; some-pict/color-table: pict-obj/color-table
; some-pict/raw-data: pict-obj/raw-data
; jpg/save some-pict or some-pict/save
]
bmp? itself would have to deal with parameter given - open %my-picture
and check file header ...
</FANTASY> :-)))
OK, that's enough I think, but the more I think about it, the more I
think it's possible to achieve with REBOL :-)
-pekr-
>
>
> Andrew Martin
> It seemed an innocent enough request at the time...
> [EMAIL PROTECTED]
> http://members.xoom.com/AndrewMartin/
> Online @ 33,600 Baud!
> -><-