emojicode / emojicode

πŸ˜€πŸ˜œπŸ”‚ World’s only programming language that’s bursting with emojis

Home Page:https://emojicode.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: read line from stdin

joeskeen opened this issue Β· comments

⭐️ Proposed change

EmojiCode allows printing to stdout using πŸ˜€, but I don't see anything in the documentation about reading input from stdin.

πŸ€” Rationale

I'd love to be able to prompt for values at runtime, or pipe input into an EmojiCode program.

Awesome, thanks. I wish there was an easier way to search the documentation for things like this.

Hmm... I guess I'm doing something wrong?

🚨 error: sπŸ”‘ has no initializer πŸ‘‚.
https://tio.run/##S83Nz8pMzk9JNfv//8P8/kaFD/N727k4P8yf0QBktk39MH/Kwg/zJzY9mjv9/Y5@IMkFVND5/39GpkJ5flFOCgA

Oh, I see... The ears color isn't right...

Do you have any way of dealing with skin tone differences? My phone's emoji keyboard only does the yellow skin tone, so I have to copy and paste, which is slightly painful. It would be interesting to have a way to alias some of those things so it doesn't matter what your skin color is πŸ˜‰

commented

The skin color is always taken into account with normal identifiers. Only languages constructs like πŸ€·β€β™€οΈ work regardless of gender and skin color.
When designing the language we have to assume that users can type all emojis, so we really don’t have any solution here.

What OS is your phone running?

I'm running OxygenOS 9.5 (Android P based) with the GBoard Google keyboard. Just did some research and discovered that you can long press the emoji to change the skin tone. That should resolve the issue.

Hello!
I'm having trouble getting user input. This current issue doesn't have any usable examples, at least for the version I have today.
I am able to compile a basic hello world program with a basic print to standard output.
I am on a Linux environment: https://repl.it/@mwilki7/emoji-language#main.emojic

Below is what I have tried.

Thanks for your help.


Method 1

Code:

🏁 πŸ‡

    πŸ˜€ πŸ”€Enter text:πŸ”€β—οΈ
    πŸ†•β–ΆοΈπŸ‘‚πŸΌ
    πŸ˜€ πŸ”€Hello World!πŸ”€β—οΈ
πŸ‰

Source: https://www.emojicode.org/docs/packages/s/1f521.html#i%F0%9F%91%82%F0%9F%8F%BC

Output:

../main.emojic:10:6: 🚨 error: Expected Identifier but instead found Operator(β–Ά).
    πŸ†•β–ΆοΈπŸ‘‚πŸΌ
     ⬆️

Method 2

Code:

🏁 πŸ‡

    πŸ˜€ πŸ”€Enter text:πŸ”€β—οΈ
    πŸ”·πŸ”‘πŸ˜―
    πŸ˜€ πŸ”€Hello World!πŸ”€β—οΈ
πŸ‰

Source: https://gitter.im/emojicode/emojicode?at=56f017f58ea88c6726736366 (search for the text "input", user marcelpatrick has a similar question)

Otto Winter @OttoWinter Mar 28 2016 05:03
😯 is an initializer for πŸ”‘, so you can call it with πŸ”·πŸ”‘πŸ˜―; this will return you a πŸ”‘ instance which you could store with 🍦in πŸ”·πŸ”‘πŸ˜―

Output:

../main.emojic:12:1: 🚨 error: Unexpected token BlockEnd.
πŸ‰β¬†οΈ

../main.emojic:12:1: 🚨 error: Unexpected end of program.
πŸ‰β¬†οΈ

Method 3

Code:

🏁 πŸ‡

    πŸ˜€ πŸ”€Enter text:πŸ”€β—οΈ
    πŸ†•πŸ”‘πŸ‘‚πŸΌβ—οΈ
    πŸ˜€ πŸ”€Hello World!πŸ”€β—οΈ
πŸ‰

Source: joeskeen's code https://tio.run/##S83Nz8pMzk9JNfv//8P8/kaFD/N727k4P8yf0QBktk39MH/Kwg/zJzY9mjv9/Y5@IMkFVND5/39GpkJ5flFOCgA

Output:

../main.emojic:12:1: 🚨 error: Unexpected token BlockEnd.
πŸ‰β¬†οΈ

../main.emojic:12:1: 🚨 error: Unexpected end of program.
πŸ‰β¬†οΈ
commented

@michaelwilkie As this is an initializer, the correct syntax is:

🏁 πŸ‡
    πŸ˜€ πŸ”€Enter text:πŸ”€β—οΈ
    πŸ†•πŸ”‘β–ΆοΈπŸ‘‚πŸΌβ—οΈ
    πŸ˜€ πŸ”€Hello World!πŸ”€β—οΈ
πŸ‰

What you were looking at in the package documentation, is a declaration and not an example. You can read more about initialization syntax here: https://www.emojicode.org/docs/reference/classes-valuetypes.html#instantiation

Thanks for the quick reply. That example works.

One last question:
How would I read that value into a variable?

commented

@michaelwilkie

🏁 πŸ‡
    πŸ˜€ πŸ”€Enter text:πŸ”€β—οΈ
    πŸ†•πŸ”‘β–ΆοΈπŸ‘‚πŸΌβ—οΈ ➑️ someText
    πŸ˜€ πŸ”€Hello World!πŸ”€β—οΈ
πŸ‰

Maybe you want to look at our getting started guide here: https://www.emojicode.org/docs/guides/compile-and-run.html

That works for me. I'll read the page more closely.
Thanks for the help!