Brain-Flak icon indicating copy to clipboard operation
Brain-Flak copied to clipboard

Phasing out -a

Open Wheatwizard opened this issue 6 years ago • 3 comments

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?

Wheatwizard avatar Dec 20 '17 01:12 Wheatwizard

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?

DJMcMayhem avatar Dec 20 '17 17:12 DJMcMayhem

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 avatar Dec 21 '17 02:12 Wheatwizard

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.

Wheatwizard avatar Dec 26 '17 02:12 Wheatwizard