from Rust:
pub(crate) bar;
means that 'bar' is public, but only within the current crate.
" You can also specify a path, like this:
pub(in a::b::c) foo;
This means “usable within the hierarchy of a::b::c, but not elsewhere.” "
---
dnautics 129 days ago [-]
you should see Julia. There's a lot of syntactic sugar that borrows from the best of other languages, for example the pipe
| > operator from elixir and do...end block syntax from ruby. |
---
golang seems to use backticks for annotations?
" var d struct { Main struct { Kelvin float64 `json:"temp"` } `json:"main"` } " -- [1]
---
i had said we wanted LL(1) syntax, but then i decided LL(k) is good enough; but some ppl like LALR (eg [2]). LALR(1) (LALR without an index refers to LALR(1)) is a subset of LR(1), and LL(k) and LALR(j) are incomparable [3], although every LL(1) grammar is also LR(1) [4]. This book says "almost all LL(1) grammars excepting some contrived examples are also LALR(1);" [5]. And this one says "class of LALR(1) grammars is large enough to include grammars for most programming languages. (This does not mean that the reference grammars for most programming languages are LALR(1): they are often ambiguous.)" [6].
There's a slide in [7] labeled "Hierarchy of grammar classes" that shows some of this as a diagram.
So i guess we want our language to be both LL(k) and LALR(k); preferably LL(1) and LALR(1). [8] has some comments on how to detect this; notably, a sufficent but not necessary condition for an LL(1) language to be LALR(1) is "if all symbols with empty derivations have non-empty derivations".
this page says "there is no way to decide if a grammar can be converted to LL(1) or to LR(1) except by trying to do it - if you succeed, then it was". [www.cs.man.ac.uk/~pjj/complang/grammar.html]
these posts talk about how to convert LALR(1) grammars to LL(k):
here's a possibly related very technical post: http://etymon.blogspot.com/2006/09/why-i-prefer-lalr-parsers.html
and another: https://compilers.iecc.com/comparch/article/01-10-069
we might also consider SLR instead of LALR(1): " LALR(1) is used in most parser generators like Yacc/Bison
We will nevertheless only see SLR in details: ((i think they mean, in this slide presentation))
---
this thread gives various examples of type-dependency in C++ parsing: https://news.ycombinator.com/item?id=11148436
---
some languages have something called 'using static CLASSNAME' which is kinda like Python's 'import * from FILENAME', except that instead of importing top-level stuff from a module, any static methods within class CLASSNAME are all imported to the top-level namespace.
sounds to me like a great way of giving the benefits of top-level functions (eg for defining new arithmetic operators) while also doing the OOP way of having everything defined inside some class
---
"#region" for documentation, and IDE expansion/collapse
---
" upper-casing exported identifiers in Go packages "
---
anywhere you can have an expression or statement, you can have a block enclosed by {}s
---
" Now, I won’t claim that C has a great syntax. If we wanted something elegant, we’d probably mimic Pascal or Smalltalk. If we wanted to go full Scandinavian-furniture-minimalism, we’d do a Scheme. Those all have their virtues.
I’m surely biased, but I think Lox’s syntax is pretty clean. C’s most egregious grammar problems are around types. Dennis Ritchie had this idea called “declaration reflects use” where variable declarations mirror the operations you would have to perform on the variable to get to a value of the base type. Clever idea, but I don’t think it worked out great in practice.
Lox doesn’t have static types, so we avoid that.
What C-like syntax has instead is something you’ll find is often more valuable in a language: familiarity "
---
" Is a language built all out of parens simple... is it free of interleaving and braiding? And the answer is no; Common Lisp and Scheme are not simple is this sense, in their use of parens. Because the use of parentheses in those languages is overloaded; parens wrap calls, they wrap grouping, they wrap data structures; and that overloading is a form of complexity... We can fix that; we can just add another data structure, it doesn't make Lisp not Lisp to have more data structures. It's still a language defined in terms of its own data structures, but having more datastructures in play means that we can get rid of this overloading in this case... " -- Rich Hickey, https://www.infoq.com/presentations/Simple-Made-Easy 0:26:03. Note: the slides say more specifically how Clojure addresses this by adding another data structure; they say, "Adding a data structure for grouping, e.g. vectors, makes each simpler"
---
complaints about C:
" For starters, hiding identifiers after arbitrarily long type expressions, instead of starting a line/block/expression with a name, is an un-fixable PITA. (Sorry, AT&T, Algol had it right)
Requiring a “break” in a case statement is a botch, instead of some kind of “or” / “set” / “range” test. "
---