PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Semantic Indentation

Semantic Indentation

Semantic Indentation is a language feature.

With this pattern, programmers indent their code blocks with whitespace instead of using braces, brackets, or other visible characters.

Languages without Semantic Indentation include Java, JavaScript, C, HTML, C++, SQL, PHP, XML, Ruby, R, Go, Perl, C#, Scala, MATLAB, Swift, MySQL, JSON, Rust, Fortran, Lua, CSS, TypeScript, Scheme, Objective-C, COBOL, Clojure, PostgreSQL, SAS, Visual Basic, Erlang, Mathematica, ARM, Kotlin, Prolog, Julia, Pascal, Ada, PowerShell, Tcl, OCaml, Dart, Groovy, Common Lisp, Bash, D, Smalltalk, Solidity, Crystal, Regular Expressions, Racket, BASIC, APL, Delphi, Chapel, Forth, Elm, CUDA, Verilog, awk, Eiffel, Reason, PostScript, Haxe, Maple, GNU Octave, LaTeX, Emacs Lisp, fish, GraphQL, Modula-2, Standard ML, Dylan, Tex, VHDL, REBOL, LLVM IR, Rexx, MUMPS, Idris, Red, SPSS, Modula-3, Simula, PL/SQL, Self, Applescript, Vala, BCPL, ANTLR, Io, Visual Basic .NET, Deno, Rust MIR, Hy, Wren, Oz, J, VBScript, SVG, Oberon, Logo, Ballerina, SNOBOL, IDL, ActionScript, Hack, TOML, Yacc, V, Protocol Buffers, Sage, CIL, OpenCL, AMPL, XQuery, HCL, MoonScript, Pike, AutoIt, Fantom, Icon, PostCSS, Limbo, Wolfram Language, Stata, SuperCollider, Agda, Perl 6, Scilab, Falcon, Seed7, Opa, Ceylon, Squirrel, JSON5, ColdFusion, Factor, PEG.js, ALGOL 60, Maxima, Xojo, X10, Bison, FLUX, Processing, Mercury, ABAP, Clean, Koka, Lasso, Eve, NewLisp, PureBasic, xBase, Befunge, E, PL/I, Terra, Zephir, Dafny, Frege, Java Bytecode, DOT, Smali, K, KaTeX, UNLAMBDA, B, Guile, API Blueprint, SETL, Object Pascal, Nginx, PRQL, ATS, LFE, AutoHotkey, Modelica, SystemVerilog, Clipper, Monkey, M4, Turing, Ini, x86 Assembly, Nearley, Pig Latin, Datalog, Fortress, Csound, LiveCode, Hjson, PicoLisp, Isabelle, unison, halide, carp, JCL, NetLogo, Sather, Transact-SQL, LPC, Flow, CIL, JAI, YASnippet, odin, CLIPS, WDL, Nextflow, Unicon, AspectJ, HOPE, PARI/GP, BETA, FreeBASIC, CWL, TLA, LotusScript, AGC, DTrace, Jison, Lily, EBNF, Fennel, QML, Lex, Cg, LilyPond, EDN, Objective-J, Classroom Object Oriented Language, SIL, NSIS, Dhall, Observable, Euphoria, Cue, idyll, Felix, JADE, Alloy, Dc, Click, Mu, Joy, S-algol, PowerBuilder, Ring, Fancy, datascript, OpenSCAD, Gambas, mgmt, PL/M, Java Properties, JFlex, NetRexx, Xtend, Tea, Refal, Ch, starlark, Logica, eC, NCAR Command Language, P4, Expect, Netwide Assembler, IGOR Pro, Oberon-2, Fibonacci, Closure Templates, ArkScript, QB64, Angelscript, Filebench WML, UrWeb, Whiley, PAWN, Mirah, SugarSS, MiniD, Apex, Not Quite C, Action!, KiXtart, ARexx, mlir, GAP, Ragel, Lingo, Neko, Ron, Golo, Volt, Augmented Backus-Naur Form, Concise Encoding, Parser 3, Pan, spry, lispyscript, Dockerfile, XSLT, CIR, JSL, Spatial, XS, OpenVera, Logtalk, PowerQuery M, MQL5, OX, mun-lang, Ren'Py, SourcePawn, Ezhil, Mask, ECL, True BASIC, Harbour, popr, DM, GDScript, Frink, Cell, Gentoo Ebuild, Hocon, CLIST, Mary, Vigil, Jasmin, MAXScript, JSON with Comments, Linden Scripting Language, MOO, Script.NET, XBase++, OCL, PowerBASIC, Strips, HiveQL, Game Maker Language, Objective C++, C shell, monte, KRL, Orc, Rescript, EuLisp, S-PLUS, Bluespec, Not eXactly C, Ion, NetLinx, Opal, Praat Script, dex, Gherkin, Eclipse Command Language, Logos, RenderScript, Mouse, WebIDL, Structured Query Reporter, BitBake, storyscript, NestedText, PIC, Cycript, LookML, SMT, COMPONENT PASCAL, POV-Ray SDL, Charity, c3, Xbasic, Raku, Jsonnet, False, Rc, BLISS, Bel, Fable, CLOS, NS Basic, FutureBASIC, spiral, neut, RELAX NG, Embedded Crystal, LoomScript, Slice, Type Language, manool, Yoix, Judoscript, Project Mentat, carth, blockml, beads-lang, Ren, Zimpl, Tuple space, Vale, ThinBasic, Adventure Game Studio Script, CartoCSS, Edje Data Collection, SRecode Template, ldpl, gentee, kai, Plus, winxed, SimCode, Language Server Index Format, owen-lang, Claro, dlvm, Caché Basic, FML, Literate Agda, Module Management System, Reactive Plan Language, Soy, Yedalog, VHDL-AMS, S3, MVEL, HAGGIS, Turbo Basic, XBLite, WxBasic, Grammatical Framework, Alpine Abuild, GCC Machine Description, Brightscript, ShaderLab, Nymph, tht, Fjölnir, Simple Actor Language System and Architecture, Lite-C, silk, Heron, taf, z80, XPL0, ISETL, ProbeVue, Recfiles, ArchieML, fizz, Guix Workflow Language, omega, Plot, rosette-lang, verifpal, Finite State Language, holyc, rbs, SubX, Maya Embedded Language, dedukti, Wart, Yet Another Scripting Language, OEM, neeilang, JCOF, hilvl, epsilon, flagship, lain, stella, txr, GraphQL Schema Definition Language, StruQL, turnstile, xxl, CFScript, StarOffice Basic, Handel-C, ActiveVFP, OptimJ, Pnuts, Action Code Script, MACRO-10, Operational Control Language, Treelang, Arden syntax, atomese, Bla, luau, wescheme, bioscript, ca65 Assembly, ctalk-lang, dslx, Manchester syntax, Portable Bit Map Format, Netpbm grayscale image format, ppm-format, rbscript, taichi, tremor-query, WebAssembly Text Format, Creative Basic, Parrot BASIC, ddfql, sora, zephyr-asdl, blz

Languages with Semantic Indentation include Python, Haskell, Elixir, F#, CoffeeScript, Nim, YAML, PureScript, Markdown, HAML, Boo, Nemerle, Occam, Makefile, Sass, ABC, Org, LiveScript, Genie, Inform, reStructuredText, wisp, Miranda, ISWIM, Stylus, Curry, Cobra, XL, Imba, Aldor, Tree Notation, SCSS, Argdown, Cirru, Spin, Quaint, I-expressions, Literate CoffeeScript, Z, Sweet Expressions, BuddyScript, PROMAL, p4p, Indental, Sheep, net-format, ELFE, CSL, converge, Ordered graph data language, MADCAP VI, MADCAP, mckeeman-form, bml

Example from Python:

class Person (object): def __init__(self, name): self.name = name

Example from PureScript:

-- https://github.com/purescript/documentation/blob/master/language/Syntax.md -- Syntax is whitespace sensitive. The general rule of thumb is that declarations which span multiple lines should be indented past the column on which they were first defined on their subsequent lines. foo = bar + baz

Example from Tree Notation:

example title Tree Notation

Example from Cirru:

print + 1 2 , 11

Example from Z:

defun message msg do print : Here's a message print msg print : End of message.

Example from Sheep:

define pythtree ax:real ay:real bx:real by:real depth:int do cx = ax-ay+by end

Article source

PLDB - Build the next great programming language. v5.0.0 - Acknowledgements · Email · GitHub