help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Using Smalltalk as a scripting language


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Using Smalltalk as a scripting language
Date: Wed, 28 Oct 2009 21:30:10 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Lightning/1.0pre Thunderbird/3.0b4

On 10/28/2009 09:20 PM, Roland Plüss wrote:
What exactly does #open do? Assuming I use a c function as #open in the
base class do I then get this function called whenever there is a
run-time problem?

It is #open: actually. The function will be passed an error message and it can print it + invoke gst_show_backtrace. However, the function should also terminate the active process, so it's better if you write it in Smalltalk.

A better choice is that you write in C a "print"-like function, and then do

    TextCollector extend [
        primWrite: aString [
            <cCall: 'roland_write_string' returning: #void args:
                   #(#string)>
        ]
    ]

    Eval [
        Transcript message: Transcript -> #primWrite:
    ]

to connect the transcript to your function.

Then you do not need a #debuggerClass at all, because you can use the default implementation of UnhandledException. You also get more flexibility, for example backtraces will include file names and line numbers instead of bytecode indices (much better!)

Regarding nil, using eval_expr is a solution, yes.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]