type codes, needed much of it, but then thought i'd try and make a general
library, for experience, but couldn't quite make it as complete as i wanted.
so reading the recent thread;
https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/fmmmgg3B1Icrang a lot of bells, and made me think it might be useful to post an idea i
got during this;
have 'range' be able to take an interface of any array, and return
interface's of the array elements.
(with basically the same thing for channels, and a range over an interface
to a none container just produce a copy.)
example:
func iterator(values interface{}) interface{} {
outchannel:= make(interface{})
go func() {
for _,v:=range values{
outchannel <- v
}
close(outchannel)
}()
return outchannel
}
values could be an interface to an array OR to a channel, which could come
from another iterator/generator.
obviously the returned value needs, at some point, to be unboxed by the
caller to the type that it knows is in the array/channel, and functions
with unboxing could be passed in as required.
possibly a compiler could optimise (avoid) the boxing/unboxing by
producing templated code for all the types actually used, and then perhaps
choose only to do this for relatively short pieces of code, and not for
long elaborate pieces, allowing code caching optimisation when fruitful?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.