Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phasing out -a #87

Open
Wheatwizard opened this issue Dec 20, 2017 · 3 comments
Open

Phasing out -a #87

Wheatwizard opened this issue Dec 20, 2017 · 3 comments

Comments

@Wheatwizard
Copy link
Collaborator

Wheatwizard commented Dec 20, 2017

Currently ASCII input in Rain-Flak is done via the -a command line argument. (example) However other interpreters such as BrainHack and BrainFlog don't have a -a flag. These interpreters use a different mixed IO method that removes the need for flags. (example) Arguments in quotes are parsed as strings and all other arguments are parsed as numbers. This method has 2 big benefits

  • It is more intuitive. To pass a string write it as a string. No need to remember which flag to use.

  • Allows for mixing of strings and integers as input, e.g. you can input 3 and "String" without forcing the 3 into string mode.

Since this has worked out well in the other interpreters perhaps we ought to include its functionality in Rain-Flak as well.

If we do add it I suggest we begin phasing out the use of -a. We ought to keep it for backwards-compatibility reasons but we might want to mark it as deprecated in future versions recommending for the new method.

What are peoples thoughts on this? Is there any reason not to add this? To what extent should we depricate -a and -c?

@DJMcMayhem
Copy link
Owner

Hmmm... I do really like the idea of mixed input. It's very useful in brain-hack. However, I'm not sure what I think about deprecating existing brain-flak answers. According to this search there are 500+ brain-flak answers written, and who knows how many of them use -a.

Can you think of a way to update to this functionality without breaking backwards compatibility?

Another issue that comes to mind, is how should strings be escaped? For example, if I wanted to input the string

hello
"world"

How would that be given to rain-flak? Something like this?

"hello
\"world\""

Which escape sequences should be valid?

@Wheatwizard
Copy link
Collaborator Author

I want to point out that deprecation does not mean removal. The feature will remain as it is but usage will be discouraged going forward. This will probably mean the flags will be removed from the help page and a warning will be given when using the flags (how we deprecate them will need some discussion).

The goal is to be backwards compatible but to prevent further usage of the flags in favor of the new system.

I'll post my thoughts on escape sequences in a bit.

@Wheatwizard
Copy link
Collaborator Author

Ok it's been more than a bit but here are my thoughts on escape sequences.

First of all escape sequences are only going to be necessary when using the -f flag (read from file). Otherwise the shell will actually handle all the chunking/escaping for us. This is not something we can overwrite. To demonstrate what I mean. To actually input the string Weird string'"\ you would need to run

$> ./BrainHack file.flk  "'Weird string'\"\\'"

However if you use a wrapper like TIO you will see that all you have to do is put quotes around the argument, (no escaping) Try it online!.

I would anticipate porting this behavior directly to Rain-Flak. The only issue is -f, here we have no shell so we need to figure out how we want to have our input parsed. My suggestion is that we try to mirror whatever ruby uses for string parsing, that way we avoid reinventing the wheel. Hopefully ruby actually has libraries for this kind of thing as well which would be pretty nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants