Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk4 min

Let’s Make a Programming Language: Functions, Scope, and Name Resolution

Adding functions to a toy language makes name lookup a scope problem. Learn how nested scopes, symbol-table searches, recursion, and return-type analysis fit together.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What happens when the same variable name exists in multiple scopes, and how does a compiler determine which one to use? In PVS-Studio’s C++ live-coding series, the functions installment takes a toy language that already has variables and uses functions to explore that practical problem: name lookup now has to account for function-local and nested local scopes.

What changes when a language adds functions?

In the preceding variables session, the toy language could declare variables, let them refer to one another, and resolve them through a global hash table. Functions make that model insufficient: a name may refer to a global declaration, a function-local declaration, or one in a nested block. PVS-Studio’s official description frames the episode’s central challenge as resolving an identifier when the same variable name exists in multiple scopes. It calls the implementation of functions “really a story about scopes and name resolution.” PVS-Studio’s webinar description presents the session as part of its live-coding language-building series.

As an Amazon Associate I earn from qualifying purchases.

The practical issue is not just recognizing function syntax. The compiler must know which declaration each use refers to, and it needs a consistent rule for choosing among declarations with the same spelling.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How does scope affect name lookup?

A scope is the region in which a declaration can be seen. A function introduces a scope for its parameters and local declarations; a nested compound statement can introduce another local scope. When a name appears in more than one of these regions, the language needs a lookup rule that relates the use to the declarations visible from its location.

The written recap of the episode describes a symbol table that associates names with declarations and scopes. It distinguishes two lookup operations:

  • Unscoped lookup: Search the current scope, then walk upward through parent scopes. Under that rule, a local declaration can take precedence over a declaration with the same name in an enclosing scope, while enclosing names remain reachable when no nearer declaration applies.
  • Scoped lookup: Check only a designated scope. The recap says this is useful for checking whether a declaration already exists in that scope, such as when preventing duplicate declarations there.

These are mechanisms described in the recap, not universal requirements for every compiler. A language’s own visibility, shadowing, and redeclaration rules determine what lookup should mean.

What function structure does the recap describe?

The DEV Community recap reports a function form with an fn keyword, a name, parameters, an optional return type, and a compound body. It says each parameter has a type and a unique name. These are details reported by that written summary; they should not be read as a complete specification of the episode’s implementation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The important design consequence is that function parameters and body declarations belong to a function’s scope, while declarations in nested compound statements may belong to more local scopes. The compiler therefore needs to preserve scope relationships while parsing and analyzing the body.

Why register a function before analyzing its body?

According to the DEV Community recap, the implementation parses and registers a function declaration before analyzing its body. That order makes the function’s own name available during analysis of the body, which is the stated mechanism for allowing self-recursion. A call to the function can then resolve to the declaration already entered in the symbol table.

This illustrates how declaration order is part of semantic analysis: even if a function’s syntax is valid, its body cannot be checked correctly until the compiler has established which declaration the function name refers to.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Where do return types fit?

The recap also describes return-type work as semantic analysis rather than just parsing. If no return type is declared, the analyzer is said to infer one from return statements; a function with no returns is treated as void. It checks that return expressions are compatible, inserts implicit casts where appropriate, and invalidates functions with incompatible returns.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Those behaviors are specific to the written recap’s account of this toy language. They are useful to distinguish from syntax parsing: parsing identifies constructs such as a return statement, while semantic checks decide whether the returned values make sense together and fit the function’s type.

What is the episode, and what is known about access?

The official PVS-Studio listing dates the C++ implementation walkthrough to August 20, 2026, at 01:00 PM UTC+1. The broader series overview says Yuri Minaev leads the sessions and describes a progression from lexer and grammar through recursive-descent parsing, variables, functions, and an evaluator. The official webinar listing marks the event as ended, but the sources do not establish whether a recording is currently available. The listing also displayed a September 24, 2026 evaluator webinar as upcoming; that date has passed, so it is not a reliable indicator of current scheduling.

For readers following the series, the functions installment is one step in a C++ live-coding project, not a general survey of how every programming language defines functions or scope.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.