sebres / tcl

The Tcl Core.
Other
3 stars 0 forks source link

tclSE / sebres tcl-fork (still private repo) #1

Open sebres opened 7 years ago

sebres commented 7 years ago

This should be a collection of all kinds of changes, fixes, refactorings in relation of the differences between both editions, and should basically describe my aim resp. the inspiration for writing of own tcl-fork (tclSE).

Not part of this repository (no public access ATM)

[Q] Why:

What I always had been missing in original tcl edition, was the inconsistent handling round about oo-objects of all kinds (no matter which engine - xotcl, itcl, etc.), the absence of many primitives and goodies that are already long time a part of many other modern languages.

Nevertheless I love tcl (and it has always been and remains my favourite language), but...

I mean:

This list is not completed and will grow, once I'll remember about something again...

[Q] What is tclSE:

Currently it is my private tcl engine, that resolves good almost all abovementioned problems. It is fast, robust and comfortable. But thereby not 100% compatible.

Here is a small list of important changes (only):

To be continued...

sebres commented 7 years ago

About sub procs. Here is a small comparison between original tcl and tclSE:

Original tcl-code (subroutine sub faked):

proc test {a b} {
  set c $a; incr c $b
  set sub {
    set prev_c $c
    incr c 100
    puts "c != a + b: $c != $a + $b"
    set c $prev_c
  }
  puts "== 1st time: =="
  puts "c == a + b: $c == $a + $b"
  set i 3; while {[incr i -1]} $sub
  puts "c == a + b: $c == $a + $b"

  puts "== 2nd time: =="
  puts "c == a + b: $c == $a + $b"
  set i 3; while {[incr i -1]} $sub
  puts "c == a + b: $c == $a + $b"
}

% test 10 20
== 1st time: ==
c == a + b: 30 == 10 + 20
c != a + b: 130 != 10 + 20
c != a + b: 130 != 10 + 20
c == a + b: 30 == 10 + 20
== 2nd time: ==
c == a + b: 30 == 10 + 20
c != a + b: 130 != 10 + 20
c != a + b: 130 != 10 + 20
c == a + b: 30 == 10 + 20

tclSE-code (subroutine sub is real sub proc), same result here:

proc test {a b} {
  set c $a; incr c $b
  sub-proc sub {} {
    ## c is local variable now after declaration bellow ("set" does it not):
    var c $c
    incr c 100
    puts "c != a + b: $c != $a + $b"
  }
  puts "== 1st time: =="
  puts "c == a + b: $c == $a + $b"
  set i 3; while {[incr i -1]} { sub }
  puts "c == a + b: $c == $a + $b"

  puts "== 2nd time: =="
  puts "c == a + b: $c == $a + $b"
  set i 3; while {[incr i -1]} { sub }
  puts "c == a + b: $c == $a + $b"
}

The pros are obvious: