TodePond / DreamBerd

perfect programming language
https://dreamberd.computer
Other
11.31k stars 347 forks source link

CEP45: Object duality #346

Open karpled opened 1 year ago

karpled commented 1 year ago

I propose to introduce a new term for objects

Object duality

Explanation

When using Luke as an example, we will look if there is such a variable. If not, then it is "Luke", otherwise we use the value of the variable.

const const Luke = Laura!
print(Luke)! // "Laura"

const const name = Luke!
print(name)! // "Laura"

Matching numbers and strings

const const a = 1!
print(a === 1)! // true

const const b = "1"!
print(b === 1)! // false

const const c = 2.5!
print(c === 2.5)! // true

const const d = string!
print(d === string)! // true

Current issues

1. Exclamation marks

const const foo = I love trains! // Obviously it is "I love trains"
const const bar = I love trains!!!! // Is it "I love trains" or "I love trains!!!"?

In that case we can use backslash as escaping?

const const foo = I love trains\!\!\!!

2. Variable name convention is missing

What is the name of a variable? Which of these is appropriate and which is not?

const const foo = foo!
const const 1 = 1!
const const 1.5 = 1.5!
const const a_b_c = a_b_c!
const const #±@%$#^!%&$% = #±@%$#^!%&$%!
const const ✨ = ✨!

P.S. No one in their right mind would call a variable Luke

Originally posted by @karpled in https://github.com/TodePond/WhenWillProgrammersStopMakingDecisionsForOurSocietyAndJustLeaveUsAloneAlsoHackerNewsIsAVileWebsite/issues/330#issuecomment-1699544509

stohrendorf commented 1 year ago

FYI, a lot of my variables are called Luke because they make the code work by using the force. I tried renaming it to Homer or Lwaxana, but it gave undefined results.

Also, I think the integrated AI is smart enough to deduce what you actually want to achieve.

TodePond commented 1 year ago

When using Luke as an example, we will look if there is such a variable. If not, then it is "Luke", otherwise we use the value of the variable.

That's right.

Is it "I love trains" or "I love trains!!!"?

It's "I love trains". Exclamation marks break out of implicit strings.

In that case we can use backslash as escaping?

Yes. Implicit strings work the same way as explicit strings in that sense.

What is the name of a variable? Which of these is appropriate and which is not?

None of these lines have any effect.

Joshix-1 commented 1 year ago

Exclamation marks break out of implicit strings. None of these lines have any effect.

How does const const #±@%$#^!%&$% = #±@%$#^!%&$%! work? (there are multiple exclamation marks) Shouldn't that be a syntax error, as const const #±@%$#^ and %&$% are weird lines? Would %&$% now be #±@%$#^? Or are the exclamation marks ignored when not in the end? (In Python you can put everythin in one line by using half-colon)

TodePond commented 1 year ago

The parser tries to parse as long a statement as possible without having to resort to implicit strings. So it behaves the same as the other lines here