Replies: 26 comments 5 replies
-
ResolutionAfter experimental confirmations carried out with Roman Susi (@rnd0101), the expression, ob-exp, of obs in a reference grammar employed for oFrugal has stabilized at ob-exp.txt.
There is no published grammar or formal description, although I have notes in support of producing those. There are essentially two levels.
There is an important difference in the level (1-2) notations. Whereas functional programming systems tend to treat f g h x as ((f g) h) x, the association of functions and their arguments in Miser has the interpretation be that of f(g(h x)) in this case. Of course, arentheses can always be used for explicit grouping. For example, the combinator S is described in Frugalese as being such that (S x) y) z = x(z) y z, using only essential parentheses. |
Beta Was this translation helpful? Give feedback.
-
Thanks! I was mainly targeting notation 1 for now. Here my take at frugal's grammar: https://github.com/rnd0101/miser/tree/master/oMiser/mockups/python but I need to add "translator" to Python yet, so that my miser can digest frugal expressions directly. (I do not have lot of time to work on this, so it gets so fragmented and surely looks from your point of view as jumping from topic to topic) |
Beta Was this translation helpful? Give feedback.
-
I also think, that probably these two notations need to be more explicit in the texts. If it's not something stable, there is probably no need for explicit ENBF or grammar, examples are enough, but I must confess it confused me on first reading. (back then I assumed it's described somewhere, so I just went on). |
Beta Was this translation helpful? Give feedback.
-
I've made a simple frugal shell with my best understanding of the grammar. (it's not ideal, does not handle corner cases well, but allows to experiment):
Update: Now I grasped it:
In a way, it's somewhat backwards to write (but makes perfect sense!):
But then the result is equivalent to:
|
Beta Was this translation helpful? Give feedback.
-
and
Is exactly it (with quoted strings as lindies). |
Beta Was this translation helpful? Give feedback.
-
Ok! So I've implemented grammar for assignment and many other things (see here) (comments and multi-line input not yet possible) In addition, I implemented frugal-level only statement sequence:
(hopefully, this will not make you feel bad about) However, application operations are now faked as before ( One idea is that That is, what could be good use for
in a standalone fashion: I believe, it is better to have separate "reading" and "evaluation" phases, just as in LISP, so some encoding is needed (for "apply", "arg list", and for "assignment"). Great bonus will be of course if that encoding will be an ob as well. Thank you for challenges! Hopefully, this helps rather than distracts you. |
Beta Was this translation helpful? Give feedback.
-
Forms of this view have been expressed in Question #10 and now Question #11. Unless there is a serious difficulty, there will be no adjustment in the following respect.
|
Beta Was this translation helpful? Give feedback.
-
The idea that f(x,y,z) simply be sugar for (((f x) y) z) goes back to Church and has been used by others. For oMiser there are no "tuple" operands signified by (x,y,z), although one can have the different pattern g[x, y, z] where the [x, y, z] is a single ob operand (and the In oFrugal notation, the |
Beta Was this translation helpful? Give feedback.
-
Probably there is some misunderstanding here (or maybe I still missed it clearly written somewhere). I do not suggest to add anything to oMiser. I am trying to figure out how to encode parsed structure in oFrugal, so that it will be correctly evaluated. By that I mean There are several options, for example, do I do not like doing it in the parser, because I think expression should be validated before starting any computations. |
Beta Was this translation helpful? Give feedback.
-
Nicely done. I introduced the ";" in my examples to disambiguate multi-line input. But having multiple statements in a line is fine too. Nice catch. There will need to be some thought on how output works for a multi-statement line. |
Beta Was this translation helpful? Give feedback.
-
as for
So, for frugal, the plumbing will be something like: hypothetical
|
Beta Was this translation helpful? Give feedback.
-
It is indeed possible to translate every oFrugal ob-exp form expression to an ob, exp, that is then evaluated via eval(exp). It would be an interesting exercise to construct that. However, it would be far more work, in the construction, and the eval(exp) would be pretty heavy-duty. Also, all of the bindings would be substituted as part of the expansion to exp. One of the powers of oMiser is the ability to have scripts that build scripts and that do what is termed "partial evaluation" in functional-programming.
I apologize that my slowness is impeding resolution of some of these matters in your eagerness to advance this. Your efforts have been very helpful but I may have to leave some of the confusing matters to the orderly treatment (such as a precise grammar) where these can be made clear. |
Beta Was this translation helpful? Give feedback.
-
You make an important point. The oFrugal REPL should probably be designed to ensure that. My thinking is that the specification of the semantics of an ob-exp would not change, and we need to see how the parser might accomplish that. There are classic ways to handle that, as in the separation of parser and code generator (in this case, ob generator). That can still be efficient. In mockups, we might not do this so well. The purpose of mockups is proof-of-concept and experimental confirmation of ideas, not production-quality software releases. |
Beta Was this translation helpful? Give feedback.
-
Thank you for reply! True, in proof-of-concept it's not needed. As we are dealing with immutable obs, time of execution probably does not matter. Well, the user experience may differ due to more cryptic error messages, but at least experiments can be carried out. |
Beta Was this translation helpful? Give feedback.
-
So I just put obap.ap into parser to quickly test and voi la - the difference is clear:
(those prints before INPUT are results of all in-parser evaluations) |
Beta Was this translation helpful? Give feedback.
-
Now added also that
|
Beta Was this translation helpful? Give feedback.
-
Although the reason the input and output are the same in the first example is because of the pure-lindy-trace rule, so the eval you do makes no difference. The eval done in the second case tears things up. I think, with your REPL, you need oMiser> (( ‵^cS :: "x") :: "y") :: "z" but there really shouldn't be an eval. I realize that I have broken the whole eval separation in the REPL idea. The only way to force eval is with an application 😉 :
should do it. It is time to step back and work through the grammar and its semantics from the top down now. I will get to that over the next couple of days, after addressing household weekend chores 😄 |
Beta Was this translation helpful? Give feedback.
-
Ok. Now it works as written in Wikipedia:
Plus this is perhaps as expected:
|
Beta Was this translation helpful? Give feedback.
-
Ah, ok. I seem not to keep up with recent developments. I will remove eval over the result. |
Beta Was this translation helpful? Give feedback.
-
I'd liked to share one meta-level comment: I believe in design of programming languages, and each design has some main principles it is guided by. For example, I like Python, because it has syntax, which is designed to be readable. Is based on least-surprise principle. It's possible to write with speed of thought. So I think design decisions need to be based on some set of principles, be them implicit or explicit. Even "look like I can only speak for myself: I have (distant) Eternal goal in mind, and it's foundational language (or technology). I am not concerned with whatever programmers are currently in favor of, be it paradigm or syntax preferences. Personally I feel oMiser is more or less ok for Eternal, but certain power-ups are needed on both expressivity ("speed to higher levels" - ability of the language to climb syntactically and in abstraction levels Forth and LISP excel at) and speed of computations (or "optimizability"). And so far it was interesting and fascinating how oFrugal with it quite simple grammar makes use of oMiser machinery. After that pair vs application mishap resolved there were many wows! along the way. |
Beta Was this translation helpful? Give feedback.
-
Small practical issue @orcmid : syntax for commands. Eg, |
Beta Was this translation helpful? Give feedback.
-
After considerable discussion, including on Question #14, here is a straightforward syntax, in original BNF, for ob-exp, the oFrugal expressions that evaluate to yield single obs. I'm using a screen capture to avoid any browser-font limitation on the Unicode characters that are used in this form of BNF. Update 2018-01-29: corrected typos caught by @rnd0101 at Question #14 The complete formal definition of the grammar along with specification of the evaluation is maintained at ob-exp.txt. |
Beta Was this translation helpful? Give feedback.
-
Wow! Now that there is a grammar and interpretation, writing oFrugal shell is a matter of expresing grammar for some lexer/parser. I will probably try Antlr4.2 as it support operator associations, so there will be no need to fight with left recursion. The (quicker?) library Please, also note one question above on how the grammar can accommodate shell commands more naturally (include, ob =, and other custom commands, eg, I have graph and solve). |
Beta Was this translation helpful? Give feedback.
-
I had preferred to just use an informal grammar for statements at this point. I can see how to provide a formal interpretation of a session, that is, for all well-formed inputs through a round of REPL inputs from start-up of oFrugal to ending, but it is getting a bit far ahead. For now, I think the only statements we need are three: include "file-reference";
ob binding-name = ob-exp ;
ob-exp ;
The command line initiation of the oFrugal REPL can have file-references to start with. There is a hash-bang convention: #! oFrugal semantic-version optional-options Also, there are no reserved words. So the ob binding-definition needs to depend on phrase up to and including the "=". Those are my only thoughts at the moment. |
Beta Was this translation helpful? Give feedback.
-
ok. What about opening up a good way for "vendor-specific" commands? In my implementation there are some interactive options etc and it could be good not to conflict with lindies. One way can be: (I think, include can have the same syntax for consistency) Added new grammar using Lark parser: https://github.com/rnd0101/miser/blob/master/oMiser/mockups/python/ofrugal_grammar.py , but not yet connected to shell as interpretation part not ready yet. |
Beta Was this translation helpful? Give feedback.
-
I don't think I have any problem with that. I want include to be part of the standard notation, because it can occur in the included files also. If you want your implementation-specific commands to be in included files as well as direct REPL statements, I suggest you use the vendor-specific flavor for those. I suspect ":" at the beginning of the line should be fine. I don't expect that any term will begin with that. On the other hand, a "::" could end up at the beginning of a line of a multi-line expression. Watch out for that, or choose a different command-line trigger character. |
Beta Was this translation helpful? Give feedback.
-
There are several examples of what is called frugalese, but is there any grammar or formal description for that?
Beta Was this translation helpful? Give feedback.
All reactions