TodePond / DreamBerd

perfect programming language
https://dreamberd.computer
Other
11.46k stars 365 forks source link

I tried running the FizzBuzz example but the compiler gave me this strange error #172

Open lunaneff opened 1 year ago

lunaneff commented 1 year ago

The given code snippet is written in a language that appears to be a mix of JavaScript and Kotlin, but it contains syntax errors and unconventional constructs. Let's break it down and point out the issues:

const var i: Int!

This line seems to be declaring a constant variable i of type Int, but the exclamation mark (!) is not valid syntax in either JavaScript or Kotlin. It's unclear what the intention is here.

when (i % 3 = 0 && i % 5 = 0) "FizzBuzz"?
else when (i % 3 = 0) "Fizz"?
else when (i % 5 = 0) "Buzz"?
else i?

This code seems to be attempting to use a when expression to determine the appropriate output based on the value of i. However, the equality check is incorrect. Instead of using =, it should use == to compare the values. Additionally, the question mark (?) is not valid syntax for conditional expressions in either JavaScript or Kotlin.

when (i < 20) i++!

The when statement here seems unnecessary and incorrect. In both JavaScript and Kotlin, the when statement is used for multi-branch conditional logic, not for looping or incrementing variables. The increment operator (++) is also not valid for a constant variable.

i = 0!

This line seems to be attempting to reassign the value of i to 0. However, the exclamation mark (!) is not valid syntax for variable assignment in either JavaScript or Kotlin.

Given the syntax errors and unconventional constructs, it's difficult to determine what the intended behavior of the code is or what it would log to the console. It seems likely that the code provided is not a valid representation of any programming language.

Any suggestions on how to make the program work would be greatly appreciated

MemerGamer commented 1 year ago

i think you can double it and give it to the next compiler

labbo-lab commented 1 year ago

DreamBerd is kinda a joke language, it wasn't really meant to be conventional, altough an interpreter is being made in #74

(Sorry, misunderstood)

lunaneff commented 1 year ago

@MemerGamer: Thanks. Copying the error message into the compiler has made it output the expected result. It also translated the code to JavaScript in the process, but I don't mind that too much.

@labbo-lab: I was just continuing the joke. The error message was generated by copy/pasting into ChatGPT as described in the readme. Cool to know that an actual implementation is being made though.