Comments (4)
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.
@geoffromer suggests that we should probably use std::abort
rather than std::exit
.
from carbon-lang.
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.
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)
- value representation for structs and tuples HOT 1
- Cant compile HOT 3
- Missing `addr` in self pointer pattern causes crash when called
- are `abstract` / `base` specifiers permitted or required on class forward declarations? HOT 2
- Is `.base` permitted as a struct member? Is it the same as `.r#base`? HOT 6
- Bazel installation for Debian Does not work
- Does the return of a template function have template phase? HOT 4
- Notation of type value arguments HOT 5
- Making `#` free HOT 14
- Allow `[]` as a part of control flows HOT 1
- Macros and user-defined control flows HOT 2
- Declaring lambdas with `fn` keyword HOT 2
- Logo is really bad HOT 2
- FATAL failure at explorer/syntax/prelude.cpp:22 HOT 3
- Bazel explorer installation error HOT 1
- Explorer crashes HOT 1
- Invalid syntax highlighting in VSCode
- Missing block string literals highlighting
- Missing filetype highlighting in block string literals
- Forward declarations of choice types HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from carbon-lang.