gator icon indicating copy to clipboard operation
gator copied to clipboard

Lack of null

Open liuhenry4428 opened this issue 5 years ago • 2 comments

Gator does not have a null keyword, but it is required for TypeScript, such as in functions that take in null as a parameter.

Current workaround: declare void null, which itself is a bug because it does not make sense for a variable to have type void.

liuhenry4428 avatar Apr 17 '20 20:04 liuhenry4428

I think null is actually a useful construct to have since it shows up a lot in C++/TS programming. Thoughts on what type it should have (I think it should be AnyTyp: anything can be null, but it doesn't interact with anything)?

Checkmate50 avatar Apr 18 '20 15:04 Checkmate50

Null is famously the billion-dollar mistake, so I think it's worth being careful about whether/how to add it. In particular, I don't think it's necessarily the case that something that shows up pervasively in C++/TS necessarily needs to be represented in Gator.

As sort of a follow-up to https://github.com/cucapra/linguine/issues/97#issuecomment-615488017, consider this: you don't have to write code exactly the same way in Gator as you do in C++ or TypeScript. Idioms that make perfect sense in "real" C++ might not need to be duplicated in Gator code that you intend to compile to C++. Instead, the philosophy could be that you write Gator code in an idiomatically Gatory style—then, the compiler takes care of implementing that code in a way that works in the target (GLSL or TypeScript or C++). If the generated code needs to use null (for example), then so be it. But the higher-level, geometrically-focused source code in Gator might not need to.

sampsyo avatar Apr 19 '20 15:04 sampsyo