Comments (2)
But now this code works:
let Link = MaybeC(Node?)
defstruct Node(
prev: Link,
data: MaybeC(X),
next: Link)
The order matters. It shouldn't, but it's what we have now.
from dssl2.
Update:
#lang dssl2
def MaybeC(c): OrC(c, NoneC)
let IntLink = MaybeC(IntNode?)
struct IntNode:
let prev: IntLink
let data: int?
let next: IntLink
class _Node[T]:
let _prev: _Link(T)
let _data: MaybeC(T)
let _next: _Link(T)
def __init__(self):
self._prev = None
self._data = None
self._next = None
def prev(self): self._prev
def data(self): self._data
def next(self): self._next
def set_prev(self, v): self._prev = v
def set_data(self, v): self._data = v
def set_next(self, v): self._next = v
def _Link(T): MaybeC(_Node?[T])
let n = _Node[int?]()
assert n.data() is None
n.set_data(5)
assert n.data() == 5
assert_error n.set_data('hello')
assert n.data() == 5
assert n.next() is None
n.set_next(n)
assert n.next() is n
n.set_next(None)
assert n.next() is None
from dssl2.
Related Issues (20)
- Multi-line comment/uncomment operations in DrRacket HOT 1
- Classes should be contracts
- Varargs functions and varargs application
- Add op-assign operators such as `+=`, `-=`, etc. HOT 2
- Different behavior when compiled with `raco make`
- Bad Error Message with Dynamic Arrays HOT 2
- Suboptimal error message when setting non-existing field HOT 1
- Grader tests fail in terminal
- Fix tests for grader. HOT 1
- Inline Struct Literals HOT 5
- Very first example in the docs is not working DSSL2 HOT 1
- Bad error message when accidentally setting a method
- Bad Error Message for Use Before Definition
- Dssl2 Installation Issues HOT 1
- Nested Higher-Order Contract Oddities
- Error message for `range` is leaky
- source location wrong in runtime error
- source location wrong in vector indexing error
- All functions print as "...e/parametric.rkt:82:10" HOT 1
- Documentation for standard library HOT 1
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 dssl2.