Comments (6)
Gotcha, yea to add to this, I think we should rename toString()
to utf8()
. That function would do validation and can return an error. string()
on the otherhand doesn't return errors and does it's best to get back something. Right now I think that behavior is to return "rawstring (20)" where 20 is the length and it does something similar with other object types. One alternative could be: it does validation and either returns the utf8 or an empty string upon error.
from cyber.
Just pushed an update for this. Also fixed some formatting issues with number and raw string slice.
from cyber.
You can achieve this with string(four)
. I'm open to adding this down the road if people like toString(). One issue I can see is it'll give the impression that every value has toString() and that would require adding a missing function fallback that may reduce performance.
from cyber.
Ah, thank you.
For what it's worth, I think string(4)
is more in-line with how number("4")
and int("4")
work currently. Is there a reason we still need foo.toString()
? In other words, could you add the functionality of foo.to_String()
into string(foo)
, then deprecate .toString()
?
from cyber.
toString() doesn't exist at the moment (Except for rawstring to get back a valid utf8 string). I'm hesitant to add it to number because it would lead to other primitives to have it too.
from cyber.
Except for rawstring to get back a valid utf8 string
Ah OK. I guess what I was suggesting is to allow users to use string(rawstring)
to get back a valid utf8 string. Then Cyber could do away with toString()
all together.
Broadly, I think having string(foo)
and foo.toString()
in the docs could confuse new users. But I'm obviously not aware of the interior mechanics and whether this is easy or difficult.
from cyber.
Related Issues (20)
- Logo Proposal HOT 2
- Performance comparison with daScript
- `nan_f64` compilation errors with latest Zig HOT 1
- I can't append list to list HOT 2
- Web Interpreter Can't Use Int Type HOT 2
- `..=` is Not Recognized as Valid Operator
- Indexed Assignment Into Non-List Type Generates "Unknown Error Code" HOT 1
- fiber example on the landing page not working HOT 1
- Cyber crashes (method with self parameter inside object) HOT 1
- frontend HOT 5
- JIT Backend
- C/C++ Backend HOT 3
- Jupyter Kernel HOT 3
- Is it possible to Implement a Cyber repl HOT 3
- Null Safety / Null Coalescing plans? HOT 1
- RFC: Replace CYON with JSON5 HOT 1
- README links are broken HOT 1
- Independent Benchmarks HOT 1
- Embeddable static library undefined symbols HOT 6
- Error occurs when compiling the examples - undefined symbol: execBytecode. HOT 4
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 cyber.