snivilised / lorax

🌟 reactive extensions for go (a pseudo rxgo version 3)
MIT License
4 stars 0 forks source link

review Duplex #297

Closed plastikfan closed 2 months ago

plastikfan commented 2 months ago

it may not be required. I think the incorrect way that some of the stream types led me down the wrong route. If we define them using '=', we avoid creating a new type meaning that the channels maintain compatibilty when passed into functions with 'end' (either chan\<- or \<-chan) specifed as the channel type, eg:

    JobStream[I any]  chan Job[I]
    JobStreamR[I any] <-chan Job[I]
    JobStreamW[I any] chan<- Job[I]

define new types, when they should probably be defined as:

    JobStream[I any]  = chan Job[I]
    JobStreamR[I any] = <-chan Job[I]
    JobStreamW[I any] = chan<- Job[I]

so a function defined as:

func somtething(inputJobCh JobStreamR[I])

can be invoked as:

    channel := make(JobStream[int])
    something(channel)

without resulting in type violation.

plastikfan commented 2 months ago

Actually, after trying to define

SourceStream[I any] = chan I

I found out that = can't be used for generic types:

generic type cannot be aliascompilerBadDecl