Suloch / chirp

Interpreter in C for rockstar programing language
MIT License
22 stars 5 forks source link

Remove unnecessary poetic literal copy and free #4

Closed meffie closed 5 years ago

meffie commented 5 years ago

The poetic literal is evaluated in place, so it is not neccessary to create a copy of it and then free the copy in the parser action. This also simplifies the parser.

Suloch commented 5 years ago

That was intentional as I wanted to keep the input buffer separate from the program functions, so that it does not accidentally modifies it. Even though makePoeticAssignment() only reads the buffer, still I kept it that way for the sake of uniformity.

meffie commented 5 years ago

I see. Shouldn't the function just declare the argument as const and let the compiler make that enforcement?

Suloch commented 5 years ago

Haha, I feel embarrassed. As you can tell, I don't much experience in making software. That should be the correct way of implementing. I am merging this as of now and will be fixing the function declaration soon.

meffie commented 5 years ago

Don't be embarrassed! There is always different ways to write code! It's good to have working code, and make improvements over time.