We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

G Sharp

From Esolang
(Redirected from User:Ractangle/G Sharp)
Jump to navigation Jump to search
G Sharp
Designed by User: Ractangle
Appeared in 2024
Computational class Unknown
Reference implementation Unimplemented
The title of this article is not correct because of technical limitations. The correct title is actually G#.
This is still a work in progress. It may be changed in the future.

G# (short for G Sharp) is an esolang with the syntax similar to Python and C. Created by User:Ractangle

Syntax

Keywords

print Self explanatory
assign name as value Creates/Edits a variable.
loop/if/else/orif While/Conditionals statement.
input Gets user input
[...] List of arguments

Classes

A Class should folow this structure:

make name(;)[
   Commands
]

Functions

To turn a Class into a Function add a return statement with arguments (because otherwise it would still treat it as a Class):

make name(;)[
  return [arguments]
  Code here
]
f[1,2]

Like in python, you can make an argument have a default value:

make f[
    return [a=value]
]

Fun fact: Functions and by extension Classes can be treated as a main class

Variables

There are types you can assign to variables (like in Python and kinda like in C with pointers), which includes:

Name Prefix
Full Shortend
string str $
integer int #
boolean bool ?
placeholder void None

"placeholder" is special as since it's the only type that can be assigned to variables

You can also assign multiple variables like in python:

assign a=b=c to void

Errors

If no class/function is found in the code:

NO MAIN CLASS FOUND IN CODE

Invalid conversion:

INCORRECT TYPE CONVERSION

Examples

Hello World

make main[
  print["Hello World\n"]
]

Cat program

make main[
  return[a]
  print[a]
]

A+B problem

make main[
  print[a+b]
  return[#a,#b]
]

Truth-machine

make main[
    if i=0 [print[0]]
    loop i [print[1]]
    return[#i]
]

99 bottles of beer

assign #bot as 99
make main [
  loop bot > 1 [
    print [
      bot,
      " bottles of beer on the wall,\n",
      bot,
      " bottles of beer.\nTake one down, Pass it around,\n"
    ]
    assign bot as #bot-1
    print[bot," bottles of beer on the wall,\n\n"] 
    ]
  ]
  print[
    bot,
    " bottle of beer on the wall,\n",
    #bot,
    " bottle of beer.\nTake one down, Pass it around,\nNo bottles of beer on the wall,\n"
  ]
]