close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 20 years ago

Closed 19 years ago

Last modified 19 years ago

#319 closed enhancement (fixed)

Struct function can yield a TOL failure

Reported by: imendez Owned by: danirus
Priority: lowest Milestone:
Component: SetAlgebra Version: head
Severity: minor Keywords:
Cc: Alfredo Torre

Description

Hi,
This code yields a TOL failure:

Set s = SetOfSet([["20050929.01.MG", "VentaLCOLCOLC",

0.0384100005031, 2395.0, 51.0]]);

Struct If(EQ(Card(s[1]), 5),
{

Text strTxt = "Struct CjtoSt(Text EstSes, Text Output, Real StdDev, Real

NumData, Real NumVar)";

Text expr = strTxt +";MakeGlobal("+ strTxt +");"+ strTxt +";";

WriteLn("Estructura de un conjunto de 5 elementos:\n"+ expr);

IncludeText(expr)

},
{

Text strTxt = "Struct CjtoSt(Text EstSes, Text Output, Real StdDev, Real

NumData)";

Text expr = strTxt +";MakeGlobal("+ strTxt +");"+ strTxt +";";

WriteLn("Estructura de un conjunto de 4 elementos:\n"+ expr);

IncludeText(expr)

});
Set h = PutStructure("CjtoSt", s[1]) ?;

This code has the same result, but I don´t know if it's the same case:

Set s = SetOfSet([["20050929.01.MG", "VentaLCOLCOLC",

0.0384100005031, 2395.0, 51.0]]);

Struct If(EQ(Card(s[1]), 5),
{

CjtoSt(Text EstSes, Text Output, Real StdDev, Real NumData, Real NumVar)

},
{

CjtoSt(Text EstSes, Text Output, Real StdDev, Real NumData)

});

Regards.

Change History (6)

comment:1 Changed 19 years ago by danirus

Priority: normallowest
Severity: blockerenhancement
Status: newassigned

It's not a Bug, it's an enhancement, so I understand you want to say this is an
urgent enhancement. We can adjust its priority to P5.

comment:2 Changed 19 years ago by danirus

Sorry, to P1 (most important)

comment:3 Changed 19 years ago by danirus

Resolution: invalid
Status: assignedclosed

This enhancement has been finally rejected.

The reason is that there are other ways to achieve the question without any
local "Struct".
"Struct" is a way to give a "Set" an structure, but it is not a Tol Type. It
would have a collision in the Global Scope if Tol could returns not only a Set
but also an Struct associatted with it when exiting from a User Function.

Iván thanks for your understanding. I hope we can talk about this in the next
meeting (Madrid, 12/12/2005). This kind of problems wouldn't exist if we had had
a good Tol Programming Style Guide.

Cheers,
Daniel

comment:4 Changed 19 years ago by imendez

Cc: Alfredo Torre added
Resolution: invalid
Status: closedreopened

Hi,

I'm very disappointed. I'll try to make all the necessary structs in the global
scope.

This one was not only an enhancement but a bug. When you compile this code:

Struct If(EQ(Card(s[1]), 5),
{

CjtoSt(Text EstSes, Text Output, Real StdDev, Real NumData, Real NumVar)

},
{

CjtoSt(Text EstSes, Text Output, Real StdDev, Real NumData)

});

TolBase crashes. I suppose TOL must return an error message without crashing.

Regards.

comment:5 Changed 19 years ago by Víctor de Buen Remiro

Resolution: fixed
Status: reopenedclosed

Struct is not an object type but a type declaration. So you cannot do Struct If(···).
Bug is in parser that should to not allow this expression and this is a very difficult
problem to solve. Afterwards MakeGlobal cannot use a name of Struct but full
declaration. Using double declaration

Text strTxt = "Struct CjtoSt(Text EstSes, Text Output, Real StdDev, Real

NumData, Real NumVar)";

Text expr = strTxt +";MakeGlobal("+ strTxt +");"+ strTxt +";";

MakeGlobal argument is invalid.

On the other hand, note that in almost all situations IncludeText is more usefull at
global level.

So, you can express that you want in this more simple way:

Set s = SetOfSet([["20050929.01.MG", "VentaLCOLCOLC",

0.0384100005031, 2395.0, 51.0]]);

Set IncludeText(If(EQ(Card(s[1]), 5),
{

Text expr = "MakeGlobal(Struct CjtoSt(Text EstSes, Text Output, Real StdDev,

Real NumData, Real NumVar));";

WriteLn("\nEstructura de un conjunto de 5 elementos:\n"+ expr+"\n");
expr

},
{

Text expr = "MakeGlobal(Struct CjtoSt(Text EstSes, Text Output, Real StdDev,

Real NumData));";

WriteLn("\nEstructura de un conjunto de 4 elementos:\n"+ expr+"\n");
expr

}));

Set h = PutStructure("CjtoSt", s[1]) ?;

comment:6 Changed 19 years ago by imendez

Thanks a lot, this was what I was loofing for.

Note: See TracTickets for help on using tickets.