Comments (8)
Oh, good catch. I was aware of this but, like you, felt like it was too much of chore it implement correctly. Or, at least, I felt it was too much of a chore right now. There are certainly more important things to work on right now. :)
Fixing it correctly isn't too hard, actually. You just have to keep a list of the lists you've already visited, and if you encounter a list that's been visited already, just print "..." instead of recursing into it. If you'd like to take a stab at it, you'd just need to:
- Write a little test case.
- Fix it in corelib.wren.
- Run
make_corelib
to slurp that code into wren_core.c. - Make sure the test passes. :)
If not, I'll get around to fixing it eventually.
from wren.
You just have to keep a list of the lists you've already visited, and if you encounter a list that's been visited already, just print "..." instead of recursing into it.
Is this needed? I think the recursion only happens when a list contains itself. Is it sufficient to only check for this?
from wren.
What if it contains a list which contains itself?
var x = []
var y = []
y.add(y)
x.add(y)
IO.print(x)
from wren.
@zeckalpha is right. To be fully general, you have to handle deeper cycles too.
from wren.
Now that I've got the concat operator, I did some work on handling toString for recursive lists:
https://github.com/zeckalpha/wren/compare/feature;toString-circular-lists
from wren.
I've done a bit more on that branch, moving the extraneous helpers in as functions inside List.toString
. Still not sure this is the right approach, and untested.
from wren.
Should that branch be ported to C and/or updated to reflect the split of List into List and Sequence?
from wren.
You won't be able to port it to C since it contains calls to toString
. Right now, primitive methods cannot call user-defined ones.
Let's just sit on this for now. I might take a stab at it later. Either way, it's not a very big issue.
from wren.
Related Issues (20)
- [Feature] Pipe Operator for Function Calls HOT 53
- [RFC] Object.responds(_) method HOT 10
- [RFC] Add routines for degrees/radians conversions HOT 21
- [RFC] Adding a `Tuple` with language support HOT 11
- [RFC] Adding `const` versions of `Object`s. HOT 9
- Class reflection for embedding HOT 3
- [RFC] `veery` lang transpiler to `wren` lang HOT 3
- [RFC] Object method message passing syntax HOT 28
- [RFC] Add `static Object.typeOf(_)` (and deprecate `Object.type` ?) HOT 9
- How can i stop wren script running? HOT 3
- Calling wren method handle from inside a bound foreign method body HOT 5
- Whitespace bugs? HOT 4
- Serialize (suspended) fibers or serialize the vm HOT 4
- wren_debug.c should use vm->config.writeFn instead of printf HOT 1
- Should we document this aspect of for loop control variable behavior?
- How do I pass a foreign object to a function call? HOT 3
- is Wren dead? HOT 2
- Where causes code to be called twice HOT 3
- How to return other foreign class obj from a foreign class ? HOT 7
- wrenCall -> foreign call causes memory corruption HOT 11
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 wren.