Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perhaps stop punning on Base functions? #26

Open
KristofferC opened this issue Sep 13, 2018 · 3 comments
Open

Perhaps stop punning on Base functions? #26

KristofferC opened this issue Sep 13, 2018 · 3 comments

Comments

@KristofferC
Copy link
Contributor

FEMBasis does some "puns" on Base functions, for example:

        function Base.size(::Type{$name})
            return ($D, $N)
        end

        function Base.size(::Type{$name}, j::Int)
            j == 1 && return $D
            j == 2 && return $N
        end

        function Base.length(::Type{$name})
            return $N
        end

length is typically defined for collections (or at least when the instance of the type is a collection). AbstractBasis is not iterable and it probably shouldn't be. Instead of defining these functions I think they should have their own names ndim, nbasis.
Overloading Base functions are typically meant so you can write generic code but there is no way to write generic code with puns like this.

@KristofferC
Copy link
Contributor Author

Another thing is that length(...) is usually the same as prod(size(...)) which this breaks.

@TeroFrondelius
Copy link
Member

Ok. This needs to change. Do you have a proposal or an idea how to change?

@ahojukka5
Copy link
Member

Yes, we could do this somehow differently. This convention originates from the need to know proper dimensions of workspace when evaluating e.g. basis functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants