#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
Priority: | normal → lowest |
---|---|
Severity: | blocker → enhancement |
Status: | new → assigned |
comment:3 Changed 19 years ago by
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
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
Cc: | Alfredo Torre added |
---|---|
Resolution: | invalid |
Status: | closed → reopened |
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
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
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]) ?;
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.