clj-commons / byte-streams

A Rosetta stone for JVM byte representations
417 stars 33 forks source link

def-transfer on seq-of #2

Closed danburkert closed 11 years ago

danburkert commented 11 years ago

Would it be possible to extend the library to allow defining transfers from (seq-of MyBytesSource) -> OtherSink? Currently when I try this I get a java.lang.RuntimeException: Unable to resolve symbol: seq-of in this context.

ztellman commented 11 years ago

seq-of is a function in the byte-streams namespace. Are you fully qualifying the name? Admittedly, I could do this for you in the def-transform macro, but that wouldn't work in convert.

danburkert commented 11 years ago

Yes, I have tried it fully qualified and through a :require alias. Here is an example that shows the error:

(ns example
  (:require [byte-streams :as bs])
  (:import [java.io OutputStream]))

;; works fine
(bs/def-conversion [OutputStream (bs/seq-of String)]
  [os]
  nil)

;; CompilerException java.lang.RuntimeException: Unable to resolve symbol: seq-of in this context
(bs/def-transfer [(bs/seq-of String) OutputStream]
  [strings os]
  nil)

Now, interestingly, if I :use bytes-streams, it works fine:

(ns example
  (:use [byte-streams])
  (:import [java.io OutputStream]))

;; works fine
(def-conversion [OutputStream (seq-of String)]
  [os]
  nil)

;; works fine
(def-transfer [(seq-of String) OutputStream]
  [strings os]
  nil)

Also, something I've noticed is def-conversion returns nil, whereas def-transfer returns the new value of the src->dst->transfer atom. Thanks for helping me track this down.

ztellman commented 11 years ago

Hmm, that's weird, that should work in either case. I'll take a look.

ztellman commented 11 years ago

This is fixed in 0.1.3