ShuggyCoUk":26xy5ubu said:
Then, regardless of your opinion on anything else in the thread, you must surely agree that your Title is grossly misleading.
What you are doing is *guaranteed* to cause more headaches, and you have no intention of changing much of it.
There's simply no point trying to assist you here, your code is a train wreck. I can only hope it is never used by anyone else as you imply.
You can consider that more than an implication - it's an outright statement: I don't code with other people, never have, and don't plan on it. My title wasn't intended to be misleading, as I seriously wanted answers about how to make it less of a headache
for me. The answers I got didn't provide the structure I was looking for, so that's when I wrote my own module, and mentioned it. I said upfront that I didn't expect to convince you career programmers it was a good idea - just that it works for me.
I'm also seriously worried at your ability to cogently design a decent DSL given what you believe is worth doing in order to achieve it.
Don't worry - be happy. I appreciate any well-intentioned help, and even some of the sarcastic jokes, as it adds to the discussion, but ultimately you're not responsible for what or how I choose to code in my spare time. But if that doesn't ease your "worry", all I can tell you is that my program is coming along nicely. It loads user input and parses it into the various objects in memory very well and gives me excellent user-friendly messages when there's a problem. That was the easy part - the harder part, which will be ongoing, is creating the infrastructure to work with those primitives and then start expanding the language.
Maarten":26xy5ubu said:
the reason that the OP is not working together with others (likely including himself) is not because he doesn't want to, but because all others have run away.
Like I said - never have, and don't plan to. I've seen the work of even accomplished programmers, and it drives me as crazy as my code would drive them. People express things in different ways. Part of my goal with my own language is to give me a better way of expressing myself in concepts that make sense to me.
ahankinson":26xy5ubu said:
Yet here you are, with a title that suggests that even your own idiomatic Python code has given you headaches in the past. You can certainly write your own way of doing it, but you came here for help.
I started this thread very early in the game. I understood python much less at the time, and I was frustrated with what I considered silly scoping rules. Now that I've written that module, I'm quite content with using python, and I find more frustration with the files I haven't switched over yet.
I'm sure you thought your switch/case was funny, but it completely misses the spirit of a select/case. A switch statement is designed to let you mention a value
just once, then branch based on conditions about that value. It reduces repetition. (Your code isn't runnable, but I'm guessing your "resfn" on the third line was intended to be at the end of the line.) Your code merely substitutes restating a 'y' with restating an 'f'. Not to mention that you lose all context when you have to call a separate function, and without a
goto, there's no easy way to
break out of the flow. Similarly, losing the context is what distinguishes gosub/return from a call to a completely different routine. (At least that's how I remember it working - it's been many years.) There are many cases in which I could write much simpler easier-to-maintain functions with gosub/return. Sure, Python is turing complete and it has some convenient features, but having a rich set of control structures is not one of them.
S. Carton: I know you were kidding, but thanks for the links - it could be interesting to study if I get a chance.
Agathos":26xy5ubu said:
I bet you could write a function decorator (call it @exceptiontracking) that automagically creates a new exception for each function, but also keeps track of whether that function was called by itself, or by another @exceptiontracking function, and treats those cases differently.
Something like that brushed my mind, but I hadn't given it much thought. The part I bolded is where I don't see how I could do that. How
can a function tell what it was called by? The traceback module lets you get a function name, but it doesn't give you a reference to the function object itself, which is the only way you could really tell them apart, since any number of functions can share the same name.
Alamout: Out of your five posts in this thread, only one of them is constructive. But that's a better record than some - keep up the good work.
LordHunter317":26xy5ubu said:
exceptions are not a bug detection mechanism!
This is what I'm trying to understand you on. I'm well aware that exceptions can't find all bugs and that they are no substitute for proper code review and testing, but do you really mean it when you say that exceptions don't help programmers catch bugs? Exceptions indicate (among other things, but quite frequently) errors. Bugs, in many cases, cause errors. Why would you say that exceptions don't detect bugs? Are you saying that it's better to not implement integrity checks, such as type-checking arguments, and just let the bug go on and do what it will lead to - just let it either result in undefined/erroneous behavior or kill the program via natural consequences instead of through a manual integrity check? What about assertions? (implemented in python via exceptions) Is Wikipedia wrong when it says: "assertions provide a very powerful tool in debugging."? I've always considered assertions, type-checking, and various other integrity checks as fundamental to writing code in which bugs have a harder time of going unnoticed. Do I have that all wrong?