2

Can anyone explain me what is the use of init.tcl?

When actually it is loaded by the TCL interpreter?

The description for this file is shown as

startup file for TCL .

But According to my knowledge .tclshrc is the start up file.

Can anyone explain this?

lfurini
  • 3,729
  • 4
  • 30
  • 48
velpandian
  • 431
  • 4
  • 11
  • 23

1 Answers1

5

Actually, init.tcl is the first file that is loaded by a Tcl_Interp*. Its job is to setup the different package loading mechanisms.

Some programs, most notably tclsh, will source the .tclshrc. This is usually done using Tcl_SourceRCFile.

So init.tcl is sourced for every Tcl interpreter, while the .tclshrc is only sourced by some programs that explicitly do that.

* does not apply to safe interpreters

lfurini
  • 3,729
  • 4
  • 30
  • 48
Johannes Kuhn
  • 14,778
  • 4
  • 49
  • 73
  • +1 to your answer.. Just i could not hold back myself from asking.. Where i can find .tclshrc file? Is it like .bashrc file? Actually i couldn't find it next to .bashrc file.. – Vishwadeep Singh Oct 01 '13 at 09:16
  • exactly. tclsh set the value of tcl_rcFileName to `~/.tclshrc` Or on windows to `~/tclshrc.tcl` – Johannes Kuhn Oct 01 '13 at 09:19
  • Let me check throughout my system. might be some where else.. :P I am using Centos5 – Vishwadeep Singh Oct 01 '13 at 09:20
  • wow! it was not there.. i created it and added all the commands to it... by default it is loading all the commands to tcl. Question went different way. Sorry – Vishwadeep Singh Oct 01 '13 at 09:28
  • The `.tclshrc` is only loaded in _interactive_ interpreters, whereas `init.tcl` is loaded in all (and it doesn't just set up package loading; that's just what the bulk of code in it does). – Donal Fellows Oct 01 '13 at 09:47
  • @DonalFellows : 'It's job is to setup the different package loading mechanisms.' I want to know the loading mechanism , i mean functionalities of init.tcl . Can you please elaborate this statement ? – velpandian Oct 01 '13 at 11:36