Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions doc/ref/debug.xml
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,8 @@ Error, recursion depth trap (5000)
[2] dive( depth - 1 );
@ *stdin*:1
... at *stdin*:4
you may 'return;'
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> return;
gap> dive(11000);
Error, recursion depth trap (5000)
Expand All @@ -932,16 +933,19 @@ Error, recursion depth trap (5000)
[2] dive( depth - 1 );
@ *stdin*:1
... at *stdin*:5
you may 'return;'
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> return;
Error, recursion depth trap (10000)
*[1] dive( depth - 1 );
@ *stdin*:1
[2] dive( depth - 1 );
@ *stdin*:1
... at *stdin*:5
you may 'return;'
brk> return;gap>
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> return;
gap>
]]></Log>
<P/>

Expand Down Expand Up @@ -981,15 +985,17 @@ Error, recursion depth trap (1000)
[2] dive( depth - 1 );
@ *stdin*:4
... at *stdin*:12
you may 'return;'
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> return;
Error, recursion depth trap (2000)
*[1] dive( depth - 1 );
@ *stdin*:4
[2] dive( depth - 1 );
@ *stdin*:4
... at *stdin*:12
you may 'return;'
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> GetRecursionDepth();
0
brk> return;
Expand Down
10 changes: 5 additions & 5 deletions doc/ref/language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,10 @@ gap> xx := 15;
15
gap> MakeReadOnlyGlobal("xx");
gap> xx := 16;
Variable: 'xx' is read only
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' after making it writable to continue
Error, Variable: 'xx' is read only
Stack trace:
not in any function at *stdin*:3
type 'quit;' to quit to outer loop
brk> quit;
gap> IsReadOnlyGlobal("xx");
true
Expand Down Expand Up @@ -1563,6 +1562,7 @@ gap> f2:= function( x ) return f1( x ); end;;
gap> f2( 4 );
value: 4
Error, Function Calls: <func> must return a value
Stack trace:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm, I added this message (or rather asked the AI to add it, but in any case, my fault); but now question that. I'll open a separate PR to explore removing it again.

*[1] f1( x )
@ *stdin*:2
<function "f2">( <arguments> )
Expand Down
36 changes: 9 additions & 27 deletions doc/ref/mloop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ indicate that you are in a break loop.
<Log><![CDATA[
gap> 1/0;
Error, Rational operations: <divisor> must not be zero
Stack trace:
not in any function at *stdin*:2
type 'quit;' to quit to outer loop
]]></Log>
Expand All @@ -487,7 +488,8 @@ If errors occur within a break loop &GAP; enters another break loop at a
<Log><![CDATA[
brk> 1/0;
Error, Rational operations: <divisor> must not be zero
not in any function at *stdin*:2
Stack trace:
not in any function at *errin*:1
type 'quit;' to quit to outer loop
brk_2>
]]></Log>
Expand Down Expand Up @@ -537,25 +539,11 @@ purpose of this function.
<Index Key="return"><K>return</K></Index>
<Index>return from break loop</Index>
The other way to leave a break loop is to <E>return</E> from a break loop.
To do this you type <C>return;</C> or <C>return <A>obj</A>;</C>.
If the break loop was entered because you interrupted &GAP;,
then you can continue by typing <C>return;</C>.
If the break loop was entered due to an error,
you may have to modify the value of a variable before typing <C>return;</C>
(see the example for&nbsp;<Ref Filt="IsDenseList"/>) or you may have to
return an object <A>obj</A>
(by typing: <C>return <A>obj</A>;</C>) to continue the computation;
in any case, the message printed on entering the break loop will
tell you which of these alternatives is possible.
For example, if the break loop was entered because a variable had no
assigned value, the value to be returned is often a value that this
variable should have to continue the computation.
<P/>
<Log><![CDATA[
brk> return 9; # we had tried to enter the divisor 9 but typed 0 ...
1/9
gap>
]]></Log>
If the break loop was entered due to an error, this option may or may not
be available, depending on the kind of error. The message printed on entering
the break loop will tell you whether this possible.

</Subsection>

Expand All @@ -581,7 +569,6 @@ function( ) ... end
gap> Error("!\n");
Error, !
Hello
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> quit;
Expand All @@ -606,8 +593,7 @@ emitted at <Ref InfoClass="InfoWarning"/> level 1
<!-- %may make it obsolete. -->
<P/>
Note that for break loops entered by a call to <Ref Func="Error"/>,
the lines after <Q><C>Entering break read-eval-print loop ...</C></Q>
and before the <C>brk></C> prompt can also be customised,
the lines just before the <C>brk></C> prompt can also be customised,
namely by redefining <Ref Func="OnBreakMessage"/>.
<P/>
<Index Key="ErrorNoTraceBack"><C>ErrorNoTraceBack</C></Index>
Expand Down Expand Up @@ -649,7 +635,6 @@ Here is a somewhat trivial demonstration of the use of
<Log><![CDATA[
gap> ErrorNoTraceBack("Gidday!", " How's", " it", " going?\n");
Error, Gidday! How's it going?
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> quit;
Expand All @@ -661,7 +646,6 @@ Now we call <Ref Func="Error"/> with the same arguments to show the difference.
gap> Error("Gidday!", " How's", " it", " going?\n");
Error, Gidday! How's it going?
Hello
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' to continue
brk> quit;
Expand All @@ -685,9 +669,8 @@ gap> OnBreak := Where;;
<Description>
<Index>Break loop message</Index>
When a break loop is entered by a call to <Ref Func="Error"/>
the message after the
<Q><C>Entering break read-eval-print loop ...</C></Q> line is produced
by the function <C>OnBreakMessage</C>,
the message at the end starting with <Q><C>you can 'quit;' to ...</C></Q>
is produced by the function <C>OnBreakMessage</C>,
which just like <Ref Func="OnBreak"/>
is a user-configurable global variable
that is a <E>function</E> with <E>no arguments</E>.
Expand Down Expand Up @@ -718,7 +701,6 @@ calling <Ref Func="Error"/> as we did above, now produces:
gap> Error("!\n");
Error, !
Hello
Entering break read-eval-print loop ...
brk> quit; # to get back to outer loop
]]></Log>
<P/>
Expand Down
10 changes: 4 additions & 6 deletions doc/ref/types.xml
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,10 @@ for an object.
<P/>
<Log><![CDATA[
gap> Setter( prop )( Rationals, false );
You cannot set an "and-filter" except to true
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can type 'return true;' to set all components true
(but you might really want to reset just one component) to continue
Error, You cannot set an "and-filter" except to true
Stack trace:
not in any function at *stdin*:8
type 'quit;' to quit to outer loop
brk>
]]></Log>
</Description>
Expand Down
9 changes: 4 additions & 5 deletions doc/tut/lists.xml
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,10 @@ gap> list[3][5] := 'w';; list; copy;
[ 1, 2, "threw", [ 4 ] ]
[ 1, 2, "three", [ 4 ] ]
gap> copy[3][5] := 'w';
List Assignment: <list> must be a mutable list
not in any function
Entering break read-eval-print loop ...
you can 'quit;' to quit to outer loop, or
you can 'return;' and ignore the assignment to continue
Error, List Assignment: <list> must be a mutable list
Stack trace:
not in any function at *stdin*:3
type 'quit;' to quit to outer loop
brk> quit;
]]></Log>
<P/>
Expand Down
16 changes: 3 additions & 13 deletions lib/list.gd
Original file line number Diff line number Diff line change
Expand Up @@ -379,30 +379,20 @@ DeclareSynonym( "AsSSortedListList", AS_LIST_SORTED_LIST );
## Lists with holes are sometimes convenient when the list represents
## a mapping from a finite, but not consecutive,
## subset of the positive integers.
## <Log><![CDATA[
## <Example><![CDATA[
## gap> IsDenseList( [ 1, 2, 3 ] );
## true
## gap> l := [ , 4, 9,, 25,, 49,,,, 121 ];; IsDenseList( l );
## false
## gap> l[3];
## 9
## gap> l[4];
## List Element: <list>[4] must have an assigned value
## not in any function
## Entering break read-eval-print loop ...
## you can 'quit;' to quit to outer loop, or
## you can 'return;' after assigning a value to continue
## brk> l[4] := 16;; # assigning a value
## brk> return; # to escape the break-loop
## 16
## gap>
## ]]></Log>
## Error, List Element: <list>[4] must have an assigned value
## ]]></Example>
## <P/>
## Observe that requesting the value of <C>l[4]</C>, which was not
## assigned, caused the entry of a <K>break</K>-loop
## (see Section&nbsp;<Ref Sect="Break Loops"/>).
## After assigning a value and typing <C>return;</C>, &GAP; is finally
## able to comply with our request (by responding with <C>16</C>).
## </Description>
## </ManSection>
## <#/GAPDoc>
Expand Down
2 changes: 1 addition & 1 deletion src/cyclotom.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static UInt FindCommonField(UInt nl, UInt nr, UInt *ml, UInt *mr)
"This computation requires a cyclotomic field of degree %d, larger "
"than the current limit of %d",
n, (Int)CyclotomicsLimit,
"You may return after raising the limit with SetCyclotomicsLimit");
"you can 'return;' after raising the limit with SetCyclotomicsLimit");
}

// Finish up
Expand Down
15 changes: 9 additions & 6 deletions src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,13 @@ void ErrorMayQuitNrAtLeastArgs(Int narg, Int actual)
*/
void ErrorReturnVoid(const Char * msg, Int arg1, Int arg2, const Char * msg2)
{
Obj LateMsg;
LateMsg = MakeString(msg2);
CallErrorInner(msg, arg1, arg2, 0, 1, LateMsg);
// ErrorMode( msg, arg1, arg2, (Obj)0, msg2, 'x' );
if (msg2 == 0) {
msg2 = "you can 'return;' to continue";
}

Obj lateMsg = MakeString("you can 'quit;' to quit to outer loop, or\n");
AppendString(lateMsg, MakeString(msg2));
CallErrorInner(msg, arg1, arg2, 0, 1, lateMsg);
}

/****************************************************************************
Expand Down Expand Up @@ -634,7 +637,7 @@ void ErrorBoundedInt(

void AssertionFailure(void)
{
ErrorReturnVoid("Assertion failure", 0, 0, "you may 'return;'");
ErrorReturnVoid("Assertion failure", 0, 0, 0);
}

void AssertionFailureWithMessage(Obj message)
Expand All @@ -645,7 +648,7 @@ void AssertionFailureWithMessage(Obj message)
AssertionFailure();
}
else if (IS_STRING_REP(message)) {
ErrorReturnVoid("Assertion failure: %g", (Int)message, 0, "you may 'return;'");
ErrorReturnVoid("Assertion failure: %g", (Int)message, 0, 0);
}
else {
PrintObj(message);
Expand Down
3 changes: 1 addition & 2 deletions src/funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ void RecursionDepthTrap( void )
if (GetRecursionDepth() > 0) {
recursionDepth = GetRecursionDepth();
SetRecursionDepth(0);
ErrorReturnVoid("recursion depth trap (%d)", (Int)recursionDepth, 0,
"you may 'return;'");
ErrorReturnVoid("recursion depth trap (%d)", (Int)recursionDepth, 0, 0);
SetRecursionDepth(recursionDepth);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hpc/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ static void InterruptCurrentThread(int locked, Stat stat)
if (handler)
CALL_WITH_CATCH(handler, NEW_PLIST(T_PLIST, 0));
else
ErrorReturnVoid("system interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("system interrupt", 0, 0, 0);
if (!locked)
pthread_mutex_unlock(thread->lock);
}
Expand Down
20 changes: 10 additions & 10 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static ALWAYS_INLINE ExecStatus ExecForHelper(Stat stat, UInt nr)
#if !defined(HAVE_SIGNAL)
// test for an interrupt
if ( HaveInterrupt() ) {
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
}
#endif

Expand Down Expand Up @@ -435,7 +435,7 @@ static ALWAYS_INLINE ExecStatus ExecForHelper(Stat stat, UInt nr)
#if !defined(HAVE_SIGNAL)
// test for an interrupt
if ( HaveInterrupt() ) {
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
}
#endif

Expand Down Expand Up @@ -530,7 +530,7 @@ static ALWAYS_INLINE ExecStatus ExecForRangeHelper(Stat stat, UInt nr)
#if !defined(HAVE_SIGNAL)
// test for an interrupt
if ( HaveInterrupt() ) {
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
}
#endif

Expand Down Expand Up @@ -666,7 +666,7 @@ static ALWAYS_INLINE ExecStatus ExecWhileHelper(Stat stat, UInt nr)
#if !defined(HAVE_SIGNAL)
// test for an interrupt
if ( HaveInterrupt() ) {
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
}
#endif

Expand Down Expand Up @@ -737,7 +737,7 @@ static ALWAYS_INLINE ExecStatus ExecRepeatHelper(Stat stat, UInt nr)
#if !defined(HAVE_SIGNAL)
// test for an interrupt
if ( HaveInterrupt() ) {
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
}
#endif

Expand Down Expand Up @@ -952,7 +952,7 @@ static ExecStatus ExecReturnObj(Stat stat)
#if !defined(HAVE_SIGNAL)
// test for an interrupt
if ( HaveInterrupt() ) {
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
}
#endif

Expand Down Expand Up @@ -980,7 +980,7 @@ static ExecStatus ExecReturnVoid(Stat stat)
#if !defined(HAVE_SIGNAL)
// test for an interrupt
if ( HaveInterrupt() ) {
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
}
#endif

Expand Down Expand Up @@ -1027,7 +1027,7 @@ UInt TakeInterrupt( void )
{
if (HaveInterrupt()) {
UnInterruptExecStat();
ErrorReturnVoid("user interrupt", 0, 0, "you can 'return;'");
ErrorReturnVoid("user interrupt", 0, 0, 0);
return 1;
}
return 0;
Expand Down Expand Up @@ -1067,12 +1067,12 @@ static ExecStatus ExecIntrStat(Stat stat)
if (printError) {
ErrorReturnVoid("reached the pre-set memory limit\n"
"(change it with the -o command line option)",
0, 0, "you can 'return;'");
0, 0, 0);
}
}
else
#endif
ErrorReturnVoid( "user interrupt", 0, 0, "you can 'return;'" );
ErrorReturnVoid("user interrupt", 0, 0, 0);
#endif

// continue at the interrupted statement
Expand Down
Loading
Loading