Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#59 closed bug (fixed)

default arguments in libs do not work

Reported by: seelisch Owned by: hannes
Priority: major Milestone: Release 3-1-0
Component: singular-libs Version:
Keywords: Cc:

Description

reported by Christian Gorzel:

Hallo Hans,

das angekuendigte

"new handling of the default argument in libraries (see Parameter list)"

mittels default-Werte ueber attrib

funktioniert A) nicht in libraries, wo man es gern haette, und

B) funktionierte immer schon.

Zu A) ----

In einer Library ist ausserhalb einer proc nicht das Schluesselwort

attrib

zugelassen, so dass

attrib(x5,"default_arg",3);

nicht funktioniert und libparse aussteigt.

Es steigt so aus, dass Singular abstuerzt. (Das ist ebenso ein generelles Problem mit libarse bei zu vielen

ungemachten schliessenden Klammern.)

Beispiel, wenn man mal attrib( ) in eine library schreibt. Die gesamte Umgebung ist weg.

LIB "/home/gorzelc/2Singular/BUG-general/11cggeneralv57.lib";

? Library /home/gorzelc/2Singular/BUG-general/11cggeneralv57.lib: ERROR

occured: in line 630, 17118.

? cannot assign character 'a' in line 630 to any group. ? Cannot load library,... aborting.

Singular : signal 11 (v: 3100/2008111315): Segment fault/Bus error occurred at 80a4226 because of c (r:1227907391) please inform the authors trying to restart...

? error occurred in STDIN line 51: `LIB

"/home/gorzelc/2Singular/BUG-general/11cggeneralv57.lib";`

listvar();

Singular : signal 11 (v: 3100/2008111315): Segment fault/Bus error occurred at 855e1e0 because of 0 (r:1227907391) please inform the authors trying to restart...

listvar();

Singular : signal 11 (v: 3100/2008111315): Segment fault/Bus error occurred at 855e1e0 because of 0 (r:1227907391) please inform the authors trying to restart...

listvar();

Singular : signal 11 (v: 3100/2008111315): Segment fault/Bus error occurred at 855e1e0 because of 0 (r:1227907391) please inform the authors gorzelc@linux:~/Desktop/Singular?/3-1-0/ix86-Linux>

Zu B) Ein Beispiel: ----

proc defaultv(i,list #) {

" This proc defaultv(i,j,k) calculates (i+j)*k .

The parameters j and k have default values j = 20 and k = 100 and may be omittied from the right.

"; if (size(#)<1 ){ #[1]=20;} if (size(#)<2 ){ #[2]=100;}

int j = #[1]; by this assignment we int k = #[2]; benefit from a desired typecheck

return((i+j)*k);

}

Dann tut's:

defaultv(1); defaultv(1,2); defaultv(1,2,-20);

Ein Hinweis bei Tipps und Tricks oder eine Ueberarbeitung der Seite sing_45.htm#SEC83 genuegte!


Gruss,

Christian

Change History (4)

comment:1 Changed 14 years ago by hannes

Resolution: fixed
Status: newclosed

attrib kann nur in Prozedurkoepern auftauchen.

comment:2 Changed 14 years ago by seelisch

Milestone: Release 3-1-0

comment:3 Changed 11 years ago by dreyer

Just having a likewise problem: Can I enforce executing a command when loading a LIB? I'm dealing with newstruct, but any prerequisites for a lib would qualify for that issue.

comment:4 Changed 11 years ago by dreyer

Solution (due to Hans) place this stuff in a procedure called mod_init.

Note: See TracTickets for help on using tickets.