Comments (6)
Yes let's stick with ints. We can wire them one-to-one in each implementation subtype of Type
, and add an abstract method int getKind()
to IExternalType, such that the types in the rascal project can comply.
Since we already have random type generation builtin, we can assert the following contract and test for violations in both the vallang and the rascal project:
Type t1, Type t2: t1.getKind().equals(t2.getKind()) <==> t1.getClass().equals(t2.getClass())
This will help if future new type kind implementations accidentally use the same int identifier.
Note that changing these identifiers in vallang in the future would lead to serious binary incompatibility of any generated Rascal/Java code that runs against this "interface". It's a highly leaky abstraction and therefore extremely volatile.
I will make this clear in code comments. Also I will write tests that assert the exact mapping from type kinds to integers, such that they can not be changed without a failing test.
from vallang.
When we have done this here, the next issue will be to apply the same design in the rascal project for all the subtypes of abstract class RascalType implements IExternalType
. Let's wait for this.
@PaulKlint all the grammatical non-terminals are implemented with the same type-kind: NonTerminalType. So there is no difference between sort
and opt
and iter
, etc for the getKind()
method. Is that ok? Or should we have different kinds for every kind of non-terminal too?
from vallang.
In org.rascalmpl.library.util.ToplevelType
you can see the enum that was used until recently, which is rather coarse.
So NonTerminal is considered as one kind. Of course, the more precise the kinds are the better discrimination we get.
But let's stick to a simple scheme for now.
from vallang.
See private message on slack. We might move this to IValue.getMatchFingerprint
for more speed and more encapsulation. That way we can also later add more precise fingerprints for different NonTerminals without breaking other code. Consider adding a possible switch case to all the switches that switch on getKind
versus adding cases to only the pattern matching code that would use getMatchFingerprint
... it's more stable and more contained. And probably much faster :-)
from vallang.
from vallang.
Closing this, as #210 is merged.
from vallang.
Related Issues (20)
- Illegal reflective access by FileChannelDirectInputStream HOT 4
- datetime creation methods fill in "current" timezone and offset (of the person running the current JVM) HOT 6
- Reduce allocations during WeakWriteLockingHashConsingMap::get HOT 34
- evaluate efficiency of new hash-consing design in pr #131 HOT 1
- illegal reflective access in FileChannelDirectInputStream HOT 10
- Parametrized data-types with extra unbound parameters lose `void` binding HOT 3
- Add informative error messages to asserts HOT 7
- StandardTextWriter does not escape keyword field names with dashes in them.
- Performance regression for transitive closure on large `rel[loc,loc]`
- TypeFactory use of `checkNull` shows up on profiles HOT 8
- Entry Buckets in ShareableValuesHashSet typically nest 4 or 5 times during a transitive closure on source locations (call graph) HOT 10
- Drop xz-java dependency HOT 1
- delete5 random test fails "sometimes" HOT 1
- add IString::asReader to stream _from_ strings HOT 15
- hashCodes of ISourceLocation implementations not uniform? HOT 2
- remove type alias feature and labels for tuple fields at run-time.
- Type covariance tests fails randomly, very rarely HOT 1
- matching an ADT with an open type parameter throws an exception
- new failing test for function matching
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 vallang.