Comments (4)
Thanks for filing an issue!
You may already understand this, but just to be clear, the current behavior is that anything, whether an integer or a character, requires a newline after it in the input. The only difference between integer and character (and for no specific good reason) is that when the play asks for a character input, only the first character is paid attention to (i.e. if the input line is "a123foobar" the input received will be "a").
I decided to write it so that it requires newlines because this way I can use the idiomatic python input
function, and it actually turns out to be more intuitive for interactive plays (i.e. when you're not piping input). I suspect the latter reason may also be the "problem" with the reference implementation.
Does that make sense? Is there an obvious design improvement I'm missing?
from shakespearelang.
Well, if one has input like abc 123 def
on a line, one would expect to be able to read input character by character. The original implementation does this; for example from that line one can read 3 (or 4) characters a
, b
, c
, and then the integer 123
. (The bug in that implementation is only that afterwards the rest of the line gets consumed, while I would expect that one can continue to read def
, character-by-character.)
With the implementation as here, there is literally no way to access characters after the first one... which makes it not very useful as a programming language.
Of course, it is debatable whether Shakespeare really is useful as a programming language in the place :-)
from shakespearelang.
I see. Now that I think about it, that does make the most sense as a strategy.
Any interest in making a PR? If not, I'll look into it when I get some time.
from shakespearelang.
@shreevatsa I've made a first pass at the implementation of this. Let me know what you think.
Reading a character gets the next character without requiring it to be followed directly by a newline:
$ printf "a1b\n2 c\nd" | shakespeare run echo.spl
a1b
Reading a number reads as many consecutive digit characters as it finds:
$ printf "a123b\n2 c\nd" | shakespeare run echo.spl
a123b
Newline characters are read explicitly, like any other character:
$ printf "a123\n" | shakespeare run echo.spl
a123
<-- note the trailing newline here
$ printf "\n123a" | shakespeare run echo.spl
<-- output starts with newline
123a
from shakespearelang.
Related Issues (9)
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 shakespearelang.