Backtracking control flow #27
Replies: 18 comments 11 replies
-
Nice catch. Should be fixed now in HEAD. I retriggered a nightly build in case you would like to try one of these. Let me know of any other problems you encounter. Or ask questions in the "Discussions" section. Or write in the alt.lang.teco newsgroup if you're old-school. PS: |
Beta Was this translation helpful? Give feedback.
-
I typed something accidentally and got segfault.., then I tried to reproduce it...
Thank you, will do. |
Beta Was this translation helpful? Give feedback.
-
Thanks. I appreciate the effort it probably took to reproduce this "something". And I hope you didn't loose any important data. I am already thinking how to improve test coverage even further. Perhaps I should generate random character sequences (with some heuristics, so they look more like TECO code) and bombard the parser. Let that run in a sandbox (FreeBSD jail) overnight and let's see what happens. And of course - it's been for ages on TODO - we still need a backup mechanism. |
Beta Was this translation helpful? Give feedback.
-
You're carrying here an interesting experiment. You could/should make an elaborate video in which you demonstrate I'll report every problem I find and I'm gonna try my best to see (and learn) about this editing paradigm... PS: After discovering a brilliant! |
Beta Was this translation helpful? Give feedback.
-
I was hoping to attract some sort of community and that somebody else would do that for me eventually. I am not really into video editing.
I also had that SNOBOL-phase in my life. ;-) |
Beta Was this translation helpful? Give feedback.
-
Just your regular workflow, should be interesting enough...
I was hoping it would be just a phase by me.| Edit: ..it WOULDN'T be... |
Beta Was this translation helpful? Give feedback.
-
Agreed. Will see to it.
You are doing some serious work in SNOBOL4? I was put off by its goto-based flow control. Never wrote more than a few scripts. (Object) Icon is in principle much more viable, but you know how it is: You can use obscure languages only for your own private projects and even there you have to weigh availability of the software and libraries against your own wishes. |
Beta Was this translation helpful? Give feedback.
-
I thought about writing the "Monkey on a typewriter"-test for SciTECO in CSNOBOL4, but it doesn't cut it either. I need both read-with-timeout (select(), poll()...) and UTF-8 support. That alone restricts me to more mainstream languages like Python or Perl. Perhaps Lua 5.3 with lposix. GNU APL actually has select(). A good chance to put another obscure language into the SciTECO repo! ;-) Well actually, if I just wrap the calls to |
Beta Was this translation helpful? Give feedback.
-
Everything I do is serious...at least for me. ;) Especially trivial everyday things with all their idiosyncrasy and my own idiosyncratic use of them, which can be scripted to make life more easy and to be more fun in general. I caught myself recently doing the same sequence of things, almost daily, at least for a few years now, and it never occurred to me it should/could be scripted. Unbelievable. As for the It gives a feel of more possibilities than recipe-like procedural languages, since you could in the instant, change the direction of the program to be/go wherever you want it to be/go. Especially with a SNOBOL4s easy, fast to type, in a word—frugal, If in something is easy to write, you don't care about readability (of it). You wanted to script something very fast (usually to elude something very boring), and it's there, it works. If we were honest, much of everyday code which we made and/or use, is not (very) pretty and we don't care since we are not (usually) publishing it and we don't care enough to polish it. It's in a way a throwaway-code which we (ironically) use for years. In one paper (Rebus — A SNOBOL4/Icon Hybrid), Griswold quotes Mark Emmer (of SPITBOL fame):
I think Iain McGilchrist (The Master and His Emissary) would agree with him, and, TBH, I would, too, now. (I wonder what (book?) sources Emmer used to get to this conclusion.) I turned off puritan inside me when I saw (and felt) what is the price.
That's true, it depends on how complex project is. I don't build nothing large ATM. I concentrate on books, on content, that's why I need something which handles strings very well... When I first found out (years, years ago) about regular expressions I was amazed, I was struck as by lighting (if you don't mind my epic-like storytelling). I coudn't imagine (for a long time) that there is an another (SNOBOL4s) way to do the same (or something more powerful). I used C for years dismissing all other languages, but that was ignorant, prejudiced (Perlis was right). I don't care anymore. String handling in C is awful and hard and/or awfully hard.., and time is precious. I was very happy when I learned it, not just that but every other idiosyncratic thing about C..., it feels now as Pyrrhic victory. (We all defend our hard-won knowledge, even though there are better ways to do the same.., that's why we disparage other approaches...[Pike said something similar.]) I love C still, but my love is not exclusive anymore. ;) BTW, what do you think about I'm sorry for this long, uncalled-for response. |
Beta Was this translation helpful? Give feedback.
-
Well actually, at the same time, almost every piece of software you will write, is buggy and will have to be fixed. So, "write once" software doesn't really exist. I had my problems understanding and debugging some of my SNOBOL scripts even very simple ones. Nothing would prevent you from supporting both GOTO and structured programming constructs. I mean theoretically, you can restrict yourself to a certain style of GOTO-programming, that is in effect structured, but you never do that.
You will like Icon as they took the backtracking algorithm and generalized it.
I use C often because it is kind of the lingua franca of computing. It's everywhere, it's portable, it's rock solid, it has direct access to all OS APIs and the largest number of libraries without any wrappers; and usually it's more flexible than people think. C++ would also tick these boxes due to its C compatibility (more or less), but is just a horrible language. Take SciTECO, sure I could have written it in a number of more hipster-languages like Rust or Zig or Go or whatever, but at the cost of restricting portability, of struggling with poorly written wrappers, with increased memory usage. And some features like it's memory limiting would be impossible at least without some C. I sometimes fear other languages, yes, I fear the bloat, the increased overall complexity of the system. If it's not some kind of experiment or optional script, I'll usually write in C.
I suppose you mean structural regexp? Can't really say much about that, as I never fully understood it. As a UI, these editors are of course interesting and I appreciate that they tried things differently. I personally do not like heavy mouse-centered approaches, though.
Never mind, I like this kind of exchange as well. Although private mail or alt.lang.teco, would probably be a better place for it. |
Beta Was this translation helpful? Give feedback.
-
Sounds very, very interesting.., don't forget about it...
Just to not be misunderstood: I like it when something is written in C, just ..., it isn't needed for everything. (For some reason I don't like python (ruby...), code looks too sterile for me.)
Not just structural regexp in general, but the way it is implemented in
Neither do I, still, some things are easier with mouse. (They all talk about speed, but it's not as relevant as ensuing fatigue from (continuous) jumping to mouse from keyboard...) |
Beta Was this translation helpful? Give feedback.
-
I wanted to add an error handling facility anyway. If branch Now let's say, we extend that a bit: In this construct, we activate undo token generation and keep a stack of macro PCs (program counters) to the beginning of the current branch. When catching an error, we undo till the PC from the stack top and then skip to the next branch. Upon reaching it, we update our macro PC. |
Beta Was this translation helpful? Give feedback.
-
With backtracking constructs, macros turn into named grammar rules. And they will of course take arguments and return values, effectively turning them into feature grammars. Actually every branch can of course return values as well. Logical programming should also be possible that way. Or Icon-style generators. It will be extremely powerful. With the right design, it could be useful in interactive editing as well. |
Beta Was this translation helpful? Give feedback.
-
Thinking some more about it, I realize it's not that easy. Actually, successful backtracking branches must not pop the backtracking stack as it may be necessary to back track into them later on and try another branch (unless we have already reached |
Beta Was this translation helpful? Give feedback.
-
Sounds really, really interesting... Maybe we should rename this issue: "Backtracking and TECO" or "SNOBOL4 and TECO"? |
Beta Was this translation helpful? Give feedback.
-
Some more brainstorming. How could Icon's "i to j" generator look like in backtracking-TECO:
Which of course demonstrates another problem: If you we need to backtrack into a macro frame, we would have to restore the macro frame, along with the local Q-Registers and the goto-label-table. So basically, in backtracking mode, the entire macro state must not be freed when a macro returns, but instead transferred to the backtracking stack. This is not even done in interactive mode since you canot rub out part of a macro call - when you rub out How could backtracking be useful during interactive usage? Suppose we do a search-replace, but would like to restrict the the places where we replace, without just updating the search pattern or adding complicated if-statements before the search-replace command. This could be solved with Icon-style goal directed programming. Further suppose that that search commands behave differently in backtracking mode and automatically find the next occurrence when backtracking - this could be coded similarly to ItoJ, but is not practical in interactive mode: |
Beta Was this translation helpful? Give feedback.
-
I read Pike's paper on structural regexp. That would of course be a nice thing to have in SciTECO. And in fact, some of it can be done in TECO with ^S and ^Y (return the length of the last pattern match). I just haven't implemented these commands yet. It is one of the next things I will do! E.g. Sam's Unfortunately, it's not that easy to realize Sam's Also, you cannot currently get and use the positions of matched subpatterns ( |
Beta Was this translation helpful? Give feedback.
-
I added Please read this section in the Wiki about structural patterns: https://github.com/rhaberkorn/sciteco/wiki/Useful-Macros#structural-patterns-apply-operations-to-part-of-buffer Not as elegant as Sam's language, but certainly more flexible. Is there anything from Sam's command language, I cannot yet model in SciTECO? |
Beta Was this translation helpful? Give feedback.
-
TECO true beginner here, anyway:
sciteco
n=
(Version: r1060.0f740ee)
Beta Was this translation helpful? Give feedback.
All reactions