6 ms·
I said nothing at all about syntax; of course it has syntax. Does Tcl have a grammar? There is a distinction and it is not irrelevant; you will run into the co
by unfocussed_mike 5y ago
I said nothing at all about syntax; of course it has syntax.
Does Tcl have a grammar? There is a distinction and it is not irrelevant; you will run into the consequences of it.
Markdown has syntax -- but no official grammar. I would not (sorry Mr Gruber) grant Markdown the privilege of being called a language in the same breath as even HTML. Markdown is a syntax looking for a grammar.
So is Tcl. So the definition of Tcl is "what the Tcl interpreter can parse". Like the Apache config file "format" is defined only by what Apache can parse.
(Curious to be downvoted for expressing what was -- twenty five, twenty years ago -- quite a big deal in scripting language circles. Tcl's lack of a grammar up against Scheme, Lisp, etc., was a point of some contention. Either way it is precisely why sane developers do not use Tcl.)
- skissane 5y ago> Does Tcl have a grammar? There is a distinction and it is not irrelevant; you will run into the consequences of it. Aren't syntax and grammar synonymous? Or, if not exactly the same thing, essentially two sides of the same coin? In my mind, a syntax is a set of well-formed formulas, a proper subset of the Kleene star of the language's alphabet. And a grammar is basically the same thing. I suppose, beyond being a mere set of WFFs, both are also a mapping from formulas to some kind of tree structure; if we can give the set of WFFs a recursive definition, then a tree structure falls out of it naturally. But, Tcl obviously has a WFF-set and a tree structure. (Although, there are also different levels of WFF-sets – the set of all syntactically/grammatically valid C programs is a proper superset of the set of all semantically valid C programs – a C program which calls an undefined function might be said to be syntactically but not semantically valid – and surely the same point holds for Tcl as well.) > Markdown has syntax -- but no official grammar. If Markdown has "no official grammar", it is because there is not one thing called Markdown, there are many. It is many sets of well-formed formulas, which are very disjoint. I suppose almost every language is many rather than one, because every implementation of a language adds a slightly different set of non-standard extensions; but in languages such as C, those differences are confined to relatively narrow areas (such as pragmas, attributes, reserved names, etc); in languages such as Markdown, the syntactic differences between different implementations will be much more extensive, so much so that we are really talking about a family of related languages (flavours as they say), rather than a single one. > So is Tcl. So the definition of Tcl is "what the Tcl interpreter can parse". The core syntax of Tcl is reasonably fixed. An independent implementation can be written to accept exactly the same core syntax as the reference implementation does, without any great effort. The non-core syntax is (near-)infinitely flexible, but I could say the same thing about C or Java. In Tcl, I can define (near-)arbitrarily named commands that accept (near-)arbitrarily named arguments; in C/C++/Java/etc I can define (near-)arbitrarily named functions/methods which accept (near-)arbitrarily named arguments, (near-)arbitrarily named structs/classes/etc which have (near-)arbitrarily named fields, etc. > Tcl's lack of a grammar up against Scheme, Lisp, etc., was a point of some contention. That claim makes zero sense to me. Tcl and Lisp have core syntaxes based on rather different principles, but both have a grammar, and I don't think there is any sensible way in which you could say that one has more of a grammar than the other.
- unfocussed_mike 5y ago> Aren't syntax and grammar synonymous? Or, if not exactly the same thing, essentially two sides of the same coin? No. (Syntax is a subset of grammar.) > If Markdown has "no official grammar", it is because there is not one thing called Markdown, there are many. No, it's also because it's a pattern-based preprocessor. There are efforts to produce Markdown grammars; some have been done. > That claim makes zero sense to me. My claim that it was a point of contention? It really was. > The non-core syntax is (near-)infinitely flexible, but I could say the same thing about C or Java. In Tcl, I can define (near-)arbitrarily named commands that accept (near-)arbitrarily named arguments; in C/C++/Java/etc I can define (near-)arbitrarily named functions/methods which accept (near-)arbitrarily named arguments, (near-)arbitrarily named structs/classes/etc which have (near-)arbitrarily named fields, etc. No, these are not the same.
- skissane 5y ago> No. (Syntax is a subset of grammar.) Can you elucidate what you see the relationship between them as being? > No, it's also because it's a pattern-based preprocessor. What do you mean by that? Why does being a "pattern-based processor" imply something has "no official grammar"? > There are efforts to produce Markdown grammars; some have been done. So, if people have produced grammars for it, it has a grammar, no? > No, these are not the same. How and why are they different?
- unfocussed_mike 5y ago> Can you elucidate what you see the relationship between them as being? Grammar covers the correct use of the syntax of a language. With syntax alone you cannot know whether a program is a correct use of a language -- that is, it will parse or compile, even if its output is nonsensical. A grammar lets you do that. So for example an unambiguous grammar is essential to being able to translate higher level language into assembly language. > What do you mean by that? Why does being a "pattern-based processor" imply something has "no official grammar"? Can you parse and transform arbitrary HTML correctly with only regular expressions? The answer as I am sure you will know is no. That is your answer here too. > So, if people have produced grammars for it, it has a grammar, no? I don't know if any Markdown grammar exists that expresses all of what you can do in the reference implementation of Markdown, so *shrug*. Maybe, maybe not. The fact that it has no deliberately designed grammar is an interoperability problem though. > How and why are they different? Because you are comparing extending semantics within what is allowed by the grammar (writing functions in the programming language it concerns) (e.g. in Java), and extending the interpreter itself (Tcl as a "language" changes according to which extensions are compiled in, and the extensions determine what the symbols mean). The fundamental question here is this: Can a program conclude that a Tcl program will parse correctly (even if the code itself has errors) without running the specific Tcl interpreter for which it is designed (or at least without knowledge of the implementation of its extensions)? No, it essentially cannot. That is what a grammar gives you. You can stare at a bit of C code you do not understand and at least say "it is valid C". And so can another program (a static analyser/explorer, a linter, etc.) More difficult with Tcl. (And perl4, for example)