You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The seq methods in "liblazy.jl" don't produce a LinkedList with the tail a succession of LazyList's for many use cases as seems to be the obvious intention. One method includes the comment: # there should maybe be a @lazy here, but tests pass, but the reason the tests pass is that they never actually check that a true nested LazyList is created at the tail. The problem is that not enough attention is paid to the definition of Type's, which is a common problem in users of dynamically typed languages.
For the method following:
seq(xs::List) = xs
just passes the argument if it is a the abstract List type, but the abstract List type includes the LinkedList type which will get passed unaltered. This can be fixed by defining this first method as follows:
seq(xs::LazyList) = xs
which passes a LazyList unaltered but all other forms of List get handled by other methods, such as the one for iterations in the case of LinkedList; this leaves the type EmptyList not handled, for which I actually disagree with the definition anyway, but for now can be handled by the following:
seq(xs::EmptyList) = xs)
The methods for Tuple and Array are terribly inefficient in allocating new Array's just dropping the first element for each iteration (partially fixed by using @view, but completely unnecessary as both are iterable, presumably efficiently, and aren't needed at all as the general case for iterables will handle them.
The default general method(s) for iterables have the major problem that they return the results of the prepend function which returns a tail of a LinkList and not a LazyList. This can be fixed for both by forcing the tail to be a LazyList as follows:
functionseq(itr, state = itr)
xs =iterate(itr, state)
xs ==nothing&&returnEmptyList()
x, state = xs
prepend(x, LazyList(() ->seq(itr, state)))
end
Finally, let's turn to testing to see why this wasn't caught, lets improve the tests to see if we are generating real LazyList's - no type checking was done whatsoever::
isa(typeof(seq([1,2,3])), Lazy.LazyList) ==true# reports false when it should be trueisa(typeof(seq(1:3)), Lazy.LazyList) ==true# reports false when it should be true
Consideration of type and type stability is seriously flawed in this library.
The text was updated successfully, but these errors were encountered:
I have the time and would be happy to issue a PR, but the problem with this library goes further than this single issue. I am currently preparing another issue, which once submitted will be the cause of (much) further discussion. Let's communicate once that is posted.
I have the time and would be happy to issue a PR, but the problem with this library goes further than this single issue. I as currently preparing another issue, which once submitted will be the cause of (much) further discussion. Let's communicate once that is posted.
The
seq
methods in "liblazy.jl" don't produce aLinkedList
with the tail a succession ofLazyList
's for many use cases as seems to be the obvious intention. One method includes the comment:# there should maybe be a @lazy here, but tests pass
, but the reason the tests pass is that they never actually check that a true nestedLazyList
is created at the tail. The problem is that not enough attention is paid to the definition of Type's, which is a common problem in users of dynamically typed languages.For the method following:
just passes the argument if it is a the abstract
List
type, but the abstractList
type includes theLinkedList
type which will get passed unaltered. This can be fixed by defining this first method as follows:which passes a
LazyList
unaltered but all other forms ofList
get handled by other methods, such as the one for iterations in the case ofLinkedList
; this leaves the typeEmptyList
not handled, for which I actually disagree with the definition anyway, but for now can be handled by the following:The methods for
Tuple
andArray
are terribly inefficient in allocating newArray
's just dropping the first element for each iteration (partially fixed by using@view
, but completely unnecessary as both are iterable, presumably efficiently, and aren't needed at all as the general case for iterables will handle them.The default general method(s) for iterables have the major problem that they return the results of the
prepend
function which returns a tail of aLinkList
and not aLazyList
. This can be fixed for both by forcing the tail to be aLazyList
as follows:Finally, let's turn to testing to see why this wasn't caught, lets improve the tests to see if we are generating real
LazyList
's - no type checking was done whatsoever::Consideration of type and type stability is seriously flawed in this library.
The text was updated successfully, but these errors were encountered: