Giter Site home page Giter Site logo

Comments (7)

sebffischer avatar sebffischer commented on August 21, 2024

This would mean, however, that there is an additional indirection because currently the list directly contains Expr and would then contain Obj::Expr. we might want to make List generic.

from r.

dgkf avatar dgkf commented on August 21, 2024

Yeah - that's certainly one concern I have. Representing ExprList as List<Obj> means that we need to do some dispatch on the Obj enum (or maybe in the future, trait) even though we know that every element is a Expr. For something as central as the language AST, this would definitely make it annoying to program around and perhaps come with a small performance hit.

We might be going off on an abstraction detour, but we could also handle Lists as heterogenous Vectors and ExprList as another homogeneous Vector<Expr> to avoid the dispatch and clean up the internal api for working with the AST.

from r.

sebffischer avatar sebffischer commented on August 21, 2024

We might be going off on an abstraction detour, but we could also handle Lists as heterogenous Vectors and ExprList as another homogeneous Vector<Expr> to avoid the dispatch and clean up the internal api for working with the AST.

Yeah, I was already wondering this for the List, let's see how easy that refactor is.

from r.

sebffischer avatar sebffischer commented on August 21, 2024

If we represent List as Vector<Obj>, we would thereby also solve #105, so maybe this is the right call.

from r.

sebffischer avatar sebffischer commented on August 21, 2024

We might be going off on an abstraction detour, but we could also handle Lists as heterogenous Vectors and ExprList as another homogeneous Vector<Expr> to avoid the dispatch and clean up the internal api for working with the AST.

Maybe this then also means that we have to refactor Vector from an enum to a Vector<T> generic. Thereby we could then conveniently use Vector<Expr> for ExprList and Vector<Obj> for List, while still not mixing ExprList, List and the other atomic vectors too much in the code base.

If you think this is a good idea, I can give this a try.

from r.

sebffischer avatar sebffischer commented on August 21, 2024

@dgkf Before I invest time in this it would be great to get your feedback on whether you would be okay with refactoring the Vector enum into a generic Vector<T>. This would mean that the Obj::Vector variant would become Obj::Character, ..., Obj::Double.
I think it would allow us to solve #105 (comment), which is on the v0.4 milestone

from r.

dgkf avatar dgkf commented on August 21, 2024

Fundamentally I have no issue with testing it out. I think we should be able to go this route even if we kept the current Obj::Vector(Vector::{Double,Character,..}) as well as Obj::List(List) where List is just a type alias for Vector<Obj>.

I lean toward this style because it will make it easier to differentiate Scalar and Array types when we get to those. If there are other benefits, then just be mindful to consider how data with different dimensions should be represented in the Obj enum.

And just regarding the milestone - I tried to tag things that looked realistic, but regardless of what makes the cut I plan to do the release in the next days. Since I don't think this is a realistic timeframe for this feature, I'm going to bump this one to 0.4.1

from r.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.