DEV Community

Josh Holbrook
Josh Holbrook

Posted on

1

Matanuska ADR 011 - Let and Assign Semantics

This article is a repost of an ADR from Matanuska BASIC, my attempt to write a BASIC interpreter in TypeScript.

Context

In a traditional BASIC, the let keyword is used for both defining variables and assigning new values to them. But this keyword is also optional - most BASIC interpreters understand i% = 1 and let i% = 1 to be synonymous.

On the other hand, many modern languages have semantic division between definition and assignment. For example, JavaScript defines variables with let or const, and uses a simple = for assigning to existing variables. This allows JavaScript to distinguish between local and non-local (or global) variables.

Python handles this in reverse - a simple = will define a local variable if it's unassigned, but the nonlocal and global keywords will allow for assigning to those kinds of variables.

Decision

In Matanuska, let will be used for defining variables, and a simple = will be used for assignment. This will allow supporting non-local variables in the future, while having syntax and idioms similar to a traditional BASIC.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay