The Ultimate Conditional Syntax

被引:0
作者
Cheng, Luyu [1 ]
Parreaux, Lionel [1 ]
机构
[1] HKUST, Hong Kong, Peoples R China
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2024年 / 8卷 / OOPSLA期
关键词
pattern matching; syntax; programming language design; POLYMORPHISM;
D O I
10.1145/3689746
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Functional programming languages typically support expressive pattern-matching syntax allowing programmers to write concise and type-safe code, especially appropriate for manipulating algebraic data types. Many features have been proposed to enhance the expressiveness of stock pattern-matching syntax, such as pattern bindings, pattern alternatives (a.k.a. disjunction), pattern conjunction, view patterns, pattern guards, pattern synonyms, active patterns, 'if-let' patterns, multi-way if-expressions, etc. In this paper, we propose a new pattern-matching syntax that is both more expressive and (we argue) simpler and more readable than previous alternatives. Our syntax supports parallel and nested matches interleaved with computations and intermediate bindings. This is achieved through a form of nested multi-way if-expressions with a condition-splitting mechanism to factor common conditional prefixes as well as a binding technique we call conditional pattern flowing. We motivate this new syntax with many examples in the setting of MLscript, a new ML-family programming language. We describe a straightforward desugaring pass from our rich source syntax into a minimal core syntax that only supports flat patterns and has an intuitive small-step semantics. We then provide a translation from the core syntax into a normalized syntax without backtracking, which is more amenable to coverage checking and compilation, and formally prove that our translation is semantics-preserving. We view this work as a step towards rethinking pattern matching to make it more powerful and natural to use. Our syntax can easily be integrated, in part or in whole, into existing as well as future programming language designs.
引用
收藏
页数:30
相关论文
共 50 条
  • [21] Polymorphic syntax definition
    Visser, E
    THEORETICAL COMPUTER SCIENCE, 1998, 199 (1-2) : 57 - 86
  • [22] The syntax of English presentatives
    Wood, Jim
    Zanuttini, Raffaella
    LANGUAGE, 2023, 99 (03) : 563 - 602
  • [23] The syntax of Sanskrit compounds
    Lowe, John J.
    LANGUAGE, 2015, 91 (03) : E71 - E115
  • [24] The syntax of intensifiers in Muishaung
    van Dam, Kellen Parker
    LINGUISTICS OF THE TIBETO-BURMAN AREA, 2020, 43 (01): : 19 - 36
  • [25] Syntax and reading comprehension: a meta-analysis of different spoken-syntax assessments
    Brimo, Danielle
    Lund, Emily
    Sapp, Alysha
    INTERNATIONAL JOURNAL OF LANGUAGE & COMMUNICATION DISORDERS, 2018, 53 (03) : 431 - 445
  • [26] On the Syntax of Russian Easy Language
    Raduenzel, Claudia
    ZEITSCHRIFT FUR SLAWISTIK, 2021, 66 (03): : 446 - 490
  • [27] When syntax meets semantics
    Gunter, TC
    Stowe, LA
    Mulder, G
    PSYCHOPHYSIOLOGY, 1997, 34 (06) : 660 - 676
  • [28] Oscillation and Oscillating Structures in Syntax
    Mendoza, Imke
    Sonnenhauser, Barbara
    ZEITSCHRIFT FUR SLAWISTIK, 2023, 68 (02): : 257 - 278
  • [29] Phonology and syntax:: a shifting relationship
    Bermúdez-Otero, R
    Honeybone, P
    LINGUA, 2006, 116 (05) : 543 - 561
  • [30] The Syntax and Semantics of Verbs of Searching
    Wang, Shan
    Chen, Shuchi
    EMERGING TECHNOLOGIES FOR EDUCATION, SETE 2021, 2021, 13089 : 122 - 141