Thank you for your quick response.

In fact, I understand what a underflow is, and I voluntarily put the
error in the example just to have a simple stack trace (but
nevertheless one which involves a quotation).

I guess we are using different versions of factor. In the 0.96, my
data stack looks like

V{ }
f
{ "kernel-error" 10 f f }

whereby you say I should have a 1 and a kernel-error.

Moreover, I do not see * above the signal-handler, but push instead.
This makes debugging more confusing. I guess this has to do with the
fact that the debugger is showing the compiled version of some words,
so the original inputs are not recognizable anymore.

In any case, I will have a look at the docs of the walker, so that I
can start making use of it.

Thank you again
Andrea

2014-10-11 16:41 GMT+02:00 John Benediktsson <mrj...@gmail.com>:
> Hi Andrea,
>
> The dialog that pops up says "data stack underflow", which given that all
> operations essentially compute on the data stack means you had insufficient
> objects on the stack for the computation. I just realized we don't document
> what this means in a very discoverable way:
>
>
> http://docs.factorcode.org/content/word-datastack-underflow.,debugger.html
>
> If you look at the traceback, you see a "1" and a kernel-error which in this
> case is the data stack underflow error tuple (perhaps we could prettyprint
> it nicer here so it matches the dialog that popped up).  In the bottom
> window, you see the computations from the top listener to the bottom where
> the signal-handler trapped the data stack underflow.  Right above the
> signal-handler you see * which was the operation that triggered it.
>
> So just with that information you can see you tried to apply the * operation
> to a 1 and nothing underneath the stack.  Essentially this error is a
> "compile-time" error, frequently due to bad stack effects, you can see this
> error isolated by
>
> 1) using infer to check the stack effects of the operation:
>
>     IN: scratchpad [ { 1 2 -2 3 } [ * ] collect-by ] infer
>
>     The input quotation to “collect-by” doesn't match its expected effect
>     Input Expected               Got
>     [ * ] ( ... obj -- ... key ) ( x x -- x )
>
> 2) putting your operation into a word, which is frequently a useful way to
> build more complex expressions, which essentially shows the same error and
> is unable to compile your expression into a word that can be called:
>
>     IN: scratchpad : foo ( seq -- seq' ) [ * ] collect-by ;
>     :errors - show 1 compiler errors
>
>     IN: scratchpad :errors
>     ...
>     The input quotation to “collect-by” doesn't match its expected effect
>     Input Expected               Got
>     [ * ] ( ... obj -- ... key ) ( x x -- x )
>
> For debugging code, I encourage you to look over the docs for the walker,
> which allows you to put breakpoints and step forward and backward and into
> code:
>
>     http://docs.factorcode.org/content/article-ui-walker.html
>
> This feedback is very helpful and we can make some improvements here -
> sometimes its easy to forgot what it was like to learn when I started
> blogging a couple years ago.
>
> Best,
> John.
>
>
> On Sat, Oct 11, 2014 at 6:59 AM, Andrea Ferretti <ferrettiand...@gmail.com>
> wrote:
>>
>> Hi, I am relatively new to Factor, and I am trying understand how to
>> debug programs in it.
>>
>> Whenever I make an error, a popup suggests to Traceback and open the
>> debugger. Now, I am used to the debugger in, say, Smalltalk, where I
>> can browse the current local variables, step into code, edit
>> definitions and so on.
>>
>> Of course the Factor debugger does not show local variables, but this
>> makes the process of debugging completely incomprehensible to me.
>>
>> For the sake of a trivial example, say I want to group a list of
>> numbers by their square, and I enter
>>
>> { 1 2 -2 3 } [ * ] collect-by
>>
>> where the correct form would be
>>
>> { 1 2 -2 3 } [ dup * ] collect-by
>>
>> I see that the call stack holds words having to do with the listener
>> thread both on top and on bottom, where I would have expected to have
>> something related to collect-by.
>>
>> The data stack only informative item is something with the name
>> "kernel-error", and the retain stack (what that even is?) holds a few
>> numbers, a few empty containers and a composition which seems the only
>> item relevant to what I have entered.
>>
>> Can someone explain the process to figure out where the error is, or
>> to analyze the situation in more detail? I have the feeling the
>> debugger is a powerful tool, but at my level of experience I cannot
>> make head or tails of it.
>>
>>
>> ------------------------------------------------------------------------------
>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>> http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> Factor-talk mailing list
>> Factor-talk@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
>
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://p.sf.net/sfu/Zoho
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to