From: drscrypt on
Does anyone know how the compiler works?

I believe a proc gets compiled after its first use automatically. Is
there a way to get its compiled representation as a string without
necessarily running the proc first? I wonder if I just compiled the
contents of a text widget one complete statement at a time and saved
their compiler versions to a file, would it be usable by tbcloader?


DrS

From: Alexandre Ferrieux on
On Mar 1, 4:07 pm, drscr...(a)gmail.com wrote:
> Does anyone know how the compiler works?
>
> I believe a proc gets compiled after its first use automatically.  Is
> there a way to get its compiled representation as a string without
> necessarily running the proc first?

See ::tcl::unsupported::disassemble

> I wonder if I just compiled the
> contents of a text widget one complete statement at a time and saved
> their compiler versions to a file, would it be usable by tbcloader?

The above [disassemble] is a (sharp) debugging tool, it doesn't
produce a tbc-compatible stream.
If you want the compiler itself for direct bytecode loading, use the
one from ActiveState.

-Alex
From: drscrypt on
Alexandre Ferrieux wrote:

> See ::tcl::unsupported::disassemble


Thanks, I will check it out.



> If you want the compiler itself for direct bytecode loading, use the
> one from ActiveState.
>

I'd thought about this, but it is really an overkill. Unless I am
wrong, it introduces licensing restrictions, I cannot redistribute it,
etc. The compiling is for a limited text editor tool and it is really
not worth all this hassle and extra cost of licensing the AS's compiler.
I thought there must be an easy way to compile scripts since it
happens by default.



DrS
From: miguel sofer on
drscrypt(a)gmail.com wrote:
> I thought there must be an easy way to compile scripts since it happens
> by default.

But ... compiling to bytecodes will not buy you much.

If you are after performance: precompiled scripts take longer to load
than the original takes to compile, so it will actually be a perf loss.

OTOH, if you are trying to hide your sources, the standard compiler will
not do - it keeps a copy of the source. The tool from AS does hide the
source, thatś what itś designed to do. The OS version is there, but
unmaintained and unlikely to work without quite some effort.
From: drscrypt on
miguel sofer wrote:
> drscrypt(a)gmail.com wrote:
>> I thought there must be an easy way to compile scripts since it
>> happens by default.
>
> But ... compiling to bytecodes will not buy you much.
>
> If you are after performance: precompiled scripts take longer to load
> than the original takes to compile, so it will actually be a perf loss.
>
> OTOH, if you are trying to hide your sources, the standard compiler will
> not do - it keeps a copy of the source.


When I distribute a script and the end users receive it, I want to
discourage them from editing it. Plain ascii just challenges the users
to open and hack things. So, I can give them just the compiled script
without any concern. (Not as app's either because these are small
scripts, there are many of them and by themselves alone they do nothing.)


So, it is not possible to compile scripts and splice them together?


DrS