Git Product home page Git Product logo

Comments (4)

jonmeow avatar jonmeow commented on May 18, 2024 1

I think the value_or part doesn't work out...

Consider:

      std::optional<const Value*> type = types.Get(ident.Name());
      if (type) {
        return TCExpression(e, *type, types);
      } else {
        FATAL_COMPILATION_ERROR(e->SourceLoc())
            << "could not find `" << ident.Name() << "`";
      }

We probably want lazy evaluation of SourceLoc() and Name(). My best idea for that was to wrap with a macro, but with an eye on maintaining lazy evaluation, the best I reached is:

      const Value* type = types.Get(ident.Name())
                              .value_or(OPTIONAL_FATAL_COMPILATION_ERROR(
                                  const Value*, (e->SourceLoc()),
                                  ("could not find `" << ident.Name() << "`")));
      return TCExpression(e, type, types);

Syntactically, I don't think this ends up being very readable. I think the macros already help a good amount with readability. So my leaning is to consider this sufficiently addressed and close. I'll leave this open a little longer if anybody wants to make suggestions for a better approach.

from carbon-lang.

dabrahams avatar dabrahams commented on May 18, 2024

@geoffromer suggests that we should probably use std::abort rather than std::exit.

from carbon-lang.

github-actions avatar github-actions commented on May 18, 2024

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the inactive label. The long term label can also be added for issues which are expected to take time.
This issue is labeled inactive because the last activity was over 90 days ago.

from carbon-lang.

jonmeow avatar jonmeow commented on May 18, 2024

I think the FATAL code partly addresses this, but the point about using value_or is interesting, maybe we can do a little more.

from carbon-lang.

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.