This is cool, thanks Zach!
Another set of mostly-isomporphic types that this could be applied to is
different matrix/array types in core.matrix. core.matrix already has
generic conversion mechanisms but they probably aren't as efficient as they
could be. I'll take a look and see if the same techniques might be
applicable.
Quick question for you and the crowd: does there exist or should we build a
standard immutable byte data representation for Clojure?
I think this is often needed: ByteBuffers and byte[] arrays work well
enough but are mutable. Byte sequences are nice and idiomatic but have a
lot of overhead, so people are often forced to resort to a variety of other
techniques. And it would be nice to support some higher level operations on
such types, e.g. production of efficient (non-copying) immutable
subsequences.
>From a data structure perspective, I'm imagining something like a
persistent data structure with byte[] data arrays at the lowest level.
Given the amount of data-processing stuff people are doing, it seems like a
reasonable thing to have in contrib at least?
On Saturday, 29 June 2013 18:57:58 UTC+1, Zach Tellman wrote:
>
> I've recently been trying to pull out useful pieces from some of my more
> monolithic libraries. The most recent result is 'byte-streams' [1], a
> library that figures how how to convert between different byte
> representations (including character streams), and how to efficiently
> transfer bytes between various byte sources and sinks. The net result is
> that you can do something like:
>
> (byte-streams/convert (File. "/tmp/foo") String {:encoding "utf-8"})
>
> and get a string representation of the file's contents. Of course, this
> is already possible using 'slurp', but you could also convert it to a
> CharSequence, or lazy sequence of ByteBuffers, or pretty much anything else
> you can imagine. This is accomplished by traversing a graph of available
> conversions (don't worry, it's memoized), so simply defining a new
> conversion from some custom type to (say) a ByteBuffer will transitively
> allow you to convert it to any other type.
>
> As an aside, this sort of conversion mechanism isn't limited to just byte
> representations, but I'm not sure if there's another large collection of
> mostly-isomorphic types out there that would benefit from this. If anyone
> has ideas on where else this could be applied, I'd be interested to hear
> them.
>
> Zach
>
> [1] https://github.com/ztellman/byte-streams
>
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.