Discussion:
[fricas-devel] first and last are "BOTH a variable and a literal"
Bill Page
2018-07-11 19:15:06 UTC
Permalink
If I use the names 'first' and 'last' in a spad file I get a message:

Semantic Errors:
[1] last is BOTH a variable and a literal
[2] first is BOTH a variable and a literal
...

What does this mean? In spite of the "semantic error" the code
compiles and runs as expected.

If I replace 'first' with a different name e.g. 'first2' and 'last'
with 'last2' then there are no such errors. So far as I know 'first'
and 'last' are not reserved words in spad.
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Raymond Rogers
2018-07-11 22:14:54 UTC
Permalink
Post by Bill Page
[1] last is BOTH a variable and a literal
[2] first is BOTH a variable and a literal
...
What does this mean? In spite of the "semantic error" the code
compiles and runs as expected.
If I replace 'first' with a different name e.g. 'first2' and 'last'
with 'last2' then there are no such errors. So far as I know 'first'
and 'last' are not reserved words in spad.
In other contexts "first" and "last" are list operators, getting the
first and last item; or in some cases a pointer.  They work as
operators  in fricas.  I would avoid trying to use them as literals  and
think they should be/reserved/ and /defined/.  Personally I wouldn't
trust "overloading" them either.  Basically I think that they come down
(up?) from Lisp.

Ray
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Bill Page
2018-07-12 03:01:07 UTC
Permalink
On Wed, Jul 11, 2018 at 4:14 PM, Raymond Rogers
Post by Bill Page
...
If I replace 'first' with a different name e.g. 'first2' and 'last'
with 'last2' then there are no such errors. So far as I know
'first' and 'last' are not reserved words in spad.
It seems like 'first' and 'last' are imported as literals from the
List domain where they are used in 'elt' to provide the notation
'x.first' and 'x.last'. These are exactly equivalent to the functions
'first x' and 'last x' also exported by List.
Post by Bill Page
In other contexts "first" and "last" are list operators, getting
the first and last item; or in some cases a pointer. They work
as operators in fricas.
Yes of course. These are operators that are exported by the List
domain constructor. The List domain constructor also exports another
other called 'elt' which can also be denoted by just a '.'. 'x.last'
is exactly equivalent to 'elt(x,last)'.
Post by Bill Page
I would avoid trying to use them as literals
FriCAS already uses them as literals. In my code I did not use them as
literals but I did define new functions with the same name. This
triggered the error message because I also use variables of type
'List'.
Post by Bill Page
and think they should be reserved and defined.
I disagree.
Post by Bill Page
Personally I wouldn't trust "overloading" them either.
Why? FriCAS does this extensively.
Post by Bill Page
Basically I think that they come down (up?) from Lisp.
No, that is not the case.
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Bill Page
2018-07-12 14:00:26 UTC
Permalink
Actually the message "Semantic Errors" occurs 35 times during a normal
successful build of FriCAS. Many but not all of these are due to
something being "BOTH a variable and a literal". Clearly these are not
really "errors". At most this might be just a helpful warning but I
cannot see any situation in SPAD where treating something as both a
variable and a literal. In fact it is not really clear what might be
meant by this message.

According to the build log there are 56 instances of using a symbol as
both a variable and a literal:

algebraicGcd2: pss1 is BOTH a variable and a literal
algebraicGcd3a: pss1 is BOTH a variable and a literal
coerce: arrows is BOTH a variable and a literal
common: contents is BOTH a variable and a literal
common: name is BOTH a variable and a literal
createSceneArrow: en is BOTH a variable and a literal
createSceneArrow: mode is BOTH a variable and a literal
createSceneArrow: offset is BOTH a variable and a literal
createSceneArrow: size is BOTH a variable and a literal
createSceneArrows: mode is BOTH a variable and a literal
createSceneArrows: size is BOTH a variable and a literal
createSceneArrow: st is BOTH a variable and a literal
createSceneLine: en is BOTH a variable and a literal
createSceneLine: st is BOTH a variable and a literal
createSceneNamedPoints: np is BOTH a variable and a literal
ddfact: degree is BOTH a variable and a literal
ddFact: degree is BOTH a variable and a literal
ddfactor: degree is BOTH a variable and a literal
do_poly_integer0: pss1 is BOTH a variable and a literal
eval: a is BOTH a variable and a literal
eval_and_solve: pss1 is BOTH a variable and a literal
eval: b is BOTH a variable and a literal
eval: c is BOTH a variable and a literal
eval: d is BOTH a variable and a literal
factorUP: x is BOTH a variable and a literal
factor: x is BOTH a variable and a literal
factor: y is BOTH a variable and a literal
finitePoset: struct1 is BOTH a variable and a literal
FloatingPointSystem: struct1 is BOTH a variable and a literal
forLoop: body is BOTH a variable and a literal
gen_exp: x is BOTH a variable and a literal
gen_exp: y is BOTH a variable and a literal
HANKP: rels is BOTH a variable and a literal
inferFromRelations: rels is BOTH a variable and a literal
jacobi2polypq : a is BOTH a variable and a literal
jacobi2polypq : b is BOTH a variable and a literal
jacobi2polypq : c is BOTH a variable and a literal
jacobi2polypq : d is BOTH a variable and a literal
lift_rightfactor: x is BOTH a variable and a literal
listream_coefsop: x is BOTH a variable and a literal
monomials1: c is BOTH a variable and a literal
monomials1: k is BOTH a variable and a literal
mul is BOTH a variable and a literal
orientedFacet: mul is BOTH a variable and a literal
proportional?: a is BOTH a variable and a literal
proportional?: b is BOTH a variable and a literal
proportional?: c is BOTH a variable and a literal
proportional?: d is BOTH a variable and a literal
ramification_of: x is BOTH a variable and a literal
reducedSystem: vec is BOTH a variable and a literal
relatorTables: rels is BOTH a variable and a literal
separateFactors: degree is BOTH a variable and a literal
sepFact1: degree is BOTH a variable and a literal
sepfact: degree is BOTH a variable and a literal
validate: last is BOTH a variable and a literal
xmlAttribute: value is BOTH a variable and a literal

--

These function names before the : above are not so useful but it would
have been a bit difficult to extract actual file names from the grep.
Anyway, the point is that if these really are not errors, then the
compiler should not flag them as such.
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Bill Page
2018-07-12 14:07:14 UTC
Permalink
Post by Bill Page
Actually the message "Semantic Errors" occurs 35 times during a
normal successful build of FriCAS. Many but not all of these are
due to something being "BOTH a variable and a literal". Clearly
these are not really "errors". At most this might be just a helpful
warning but I cannot see any situation in SPAD where treating
something as both a variable and a literal ...
could cause a problem.
Post by Bill Page
In fact it is not really clear what might be
meant by this message.
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Waldek Hebisch
2018-07-12 14:06:29 UTC
Permalink
Post by Bill Page
[1] last is BOTH a variable and a literal
[2] first is BOTH a variable and a literal
...
What does this mean? In spite of the "semantic error" the code
compiles and runs as expected.
If I replace 'first' with a different name e.g. 'first2' and 'last'
with 'last2' then there are no such errors. So far as I know 'first'
and 'last' are not reserved words in spad.
This is mainly due to using the same name for variables and record
fields. Original authors of Spad compiler for same reason decided
that this is an error. But AFAICS there are no problems due to
this so this is accepted, but still produces an error message.
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
Loading...