GithubHelp home page GithubHelp logo

Line continuation in curly braces about jimtcl HOT 8 OPEN

msteveb avatar msteveb commented on May 25, 2024
Line continuation in curly braces

from jimtcl.

Comments (8)

dbohdan avatar dbohdan commented on May 25, 2024

Another way the difference manifests:

$ cat demo2.tcl 
puts [list {*}{foo\
               bar}]
$ tclsh demo2.tcl 
foo bar
$ jimsh demo2.tcl 
{foo } bar

from jimtcl.

dbohdan avatar dbohdan commented on May 25, 2024

If you're interested, I've just pushed a number of tests for Tcl 8-compatible handling of line continuations to Picol's repo.

from jimtcl.

msteveb avatar msteveb commented on May 25, 2024

Thanks for the report. I was aware of this incompatibility with Tcl but I didn't see it as a significant feature. (i.e. I've never needed it). I would be happy to hear specific issues with this missing feature aside from simply incompatibility.

from jimtcl.

dbohdan avatar dbohdan commented on May 25, 2024

The issues I have seen come down to long string literals with meaningful whitespace being corrupted in code that otherwise works in Jim. The most common has probably been help messages displayed incorrectly when written like the one below.

puts stderr {Lorem ipsum dolor sit amet, consectetur\
             adipiscing elit. Aenean non pharetra\
             metus, vitae tristique sem. Praesent\
             at sapien non nibh suscipit ultrices.}

Those are only an annoyance. More important, though far less common, have been problems with multiline regular expressions and document templates. For example,

if {[regexp {a very long regular expression split on a word\
             boundary} $foo]} ...
set template {
...
        <deeply>
          <nested>
            <tags foo="a" bar="b" \
                  baz="c">
              %5$s
            </tags>
...
}

from jimtcl.

msteveb avatar msteveb commented on May 25, 2024

Here, is a fix: https://gist.github.com/msteveb/bc468decd86293c185e498adff9a2199

But unfortunately it breaks line numbering:

source-1.2 ERR Line numbers after command with escaped newlines
At      : stacktrace.test:53
Expected: 'stacktrace.test 43'
Got     : 'stacktrace.test 41'

source-1.3 ERR Line numbers after string with newlines
At      : stacktrace.test:56
Expected: 'stacktrace.test 47'
Got     : 'stacktrace.test 45'

source-1.4 ERR Line numbers after string with escaped newlines
At      : stacktrace.test:59
Expected: 'stacktrace.test 51'
Got     : 'stacktrace.test 47'

 stacktrace.test: Total    45   Passed    42  Skipped     0  Failed     3

I don't see any easy way around this. I prefer line numbering to be correct.

from jimtcl.

dbohdan avatar dbohdan commented on May 25, 2024

Thanks for the patch! Yes, I agree it's a bad regression. So far I've spent a couple of hours trying to hack up a solution localized to just ScriptObjAddTokens and JimMakeScriptObj. I see a way to do it by attaching metadata about the squashed newlines' offsets to the script object, but this solution would be cumbersome and ugly. An alternative is to refactor the parser. I'll get back to you if I implement either.

from jimtcl.

The-Markitecht avatar The-Markitecht commented on May 25, 2024

I wonder if this is also the root cause of the error I get whenever I break a long list of proc parameters into 2 lines, in version 0.79:

$ cat proc.tcl 
proc p {a \
    b} {
    puts $b
}

p one two

$ ./jimsh proc.tcl 
proc.tcl:1: Error: argument with no name
at file "proc.tcl", line 1

I run into that often, and it's annoying. I'm in the habit of doing it that way, from Tcl 8.x

Just now I did find that removing the backslash makes it work:

$ cat proc.tcl 
proc p {a
    b} {
    puts $b
}

p one two

$ ./jimsh proc.tcl 
two

Is that the same workaround y'all use? I wouldn't want any interp changes that break line numbering in stack dumps. The line numbering is one of THE MAJOR reasons I've adopted Jim across the board. Its absence in Tcl 8.x is simply ASTONISHING to me.

from jimtcl.

msteveb avatar msteveb commented on May 25, 2024

I agree regarding line numbers and I wouldn't want to give it up for this feature. If anyone implements an elegant solution to this, I'm happy to consider it. In the meantime, yes I simply remove the backslashes.

from jimtcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.