in reply to Re: making perl more forgiving
in thread making perl more forgiving

Since perl already detects runaway strings
The fact that a compiler can figure out that you forgot to close off a string doesn't mean the compiler has any idea where this happened.
Perhaps in perl6 we could have a module that fires up when the compile fails and tries to mangle the code near the syntax error until it compiles.
What would be the point? Clearly it can't do it silently because it might mangle it to something that compiles, but doesn't do what the programmer intended. OTOH, if it can't be silenced, the programmer wants to fix the mistake anyway, because otherwise the compiler will split out messages each time the program is run.
I suspect that this is getting downvotes because people don't like the idea of a compiler automatically correcting their mistakes.
I think a compiler that automatically corrects mistakes would be wonderful. I'm sure that someone who manages to make a compiler that corrects mistakes correctly has a pretty good chance of winning a Turing award.
But I do like the idea of a compiler printing out "syntax error at line 65, did you mean 'print "foxx"' instead?"
How much different from "Might be a runaway multi-line "" string starting on line N" is that?

Abigail

Replies are listed 'Best First'.
Re: Re: making perl more forgiving
by jepri (Parson) on May 16, 2004 at 01:33 UTC
    Well, I had my epiphany in the chatbox, so I might as well share.

    If the compiler worked like a spell checker, it could pop up a dialog and say "Detected a syntax error xxx, I think you should change your code to yyy. Shall I change it?"

    I spend a lot of my debugging time nailing spelling errors and missing braces. I'd rather the compiler took a guess and asked me if it was right. Pressing 'y' five times would be so much nicer than having to get back into the text editor 5 times. And if I have to press 'n' and fix it by hand, I've lost nothing.

    How much different from "Might be a runaway multi-line "" string starting on line N" is that?

    Just as a more useful example, why not use Symbol::Approx to guess what function I misspelled, and then suggest the correction to me?

    Or how about 'Detected missing semicolon at line 33, shall I correct?' Why is it a good use of my time to correct this trivial problem by hand?

    Or how about "Unmatched left brace at line 133, but if I pop a brace in front of the next 'sub xxx', I can compile. Want me to fix it?"

    ____________________
    Jeremy
    I didn't believe in evil until I dated it.

      Patches welcome.

      Abigail

        Thanks for the invite. Perl5 is much to scary for me, but I'll play around with some code for Perl6 - provided someone doesn't beat me to it. :)

        Every time I think I have a good idea for perl6, I discover someone is already doing it. It is very encouraging.

        When the compiler is a little more baked I'll look at where to plug the code in.

        ____________________
        Jeremy
        I didn't believe in evil until I dated it.

    A reply falls below the community's threshold of quality. You may see it by logging in.