Dear all,

writing code for apportionment methods (election, votes and seats) I
heavily need floor and ceiling: % -> Integer - the code should work for
Fraction Integer, DecimalExpansion and Floats

However, the two method in Float have signatures floor, ceiling: % -> %
(should be unified to have function name overloading).
One way out is to define a ExtendedFloat (EFLOAT) with these 2
signatures added, which I did

and having the following conditional code for a package parametrized by
a field K:

if K has with (floor: K -> Integer; ceiling: K -> Integer)

It then works, but in the interpreter I get an error for this:

(297) -> EFLOAT has with (floor: % -> Integer; ceiling: % -> Integer)
   Internal Error
   Unexpected error in call to system function pf2Sex1


Questions to syntax variations of this:

It also compiles if one drops the "with"

if K has with (floor: K -> Integer; ceiling: K -> Integer)

Can someone give a detailed description of the syntax and semantics of
"with"?


Things becomes more complicated using infix functions, which I also have
to use:

if K has with ("^": (K, Fraction Integer) -> K) then

The following behaviour is surprising: I extended Fraction Integer do
ExtendedFraction Integer to include such an approximating powering also
for the rational numbers. Then my package with parameter K = Extended
Fraction Integer recognizes the signatures defined under this condition.
However, the normal Float, which has such a signature implemented in the
system is not recognized. Mysterious.

Testing in the interpreter fails using "with"

(301) -> Float has with ("^": (%, Fraction Integer) -> %)

  Line   1: Float has with ("^": (%, Fraction Integer) -> %)
           ...............AB
  Error  A: Missing mate.
  Error  B: syntax error at top level
  Error  B: Possibly missing a )
   3 error(s) parsing

(301) -> Float has with (^: (%, Fraction Integer) -> %)

   Internal Error
   Unexpected error in call to system function pf2Sex1

(301) -> Float has with (_^: (%, Fraction Integer) -> %)

   Internal Error
   Unexpected error in call to system function pf2Sex1


However it works (partially) without the "with":


(302) -> Float has  (_^: (%, Fraction Integer) -> %)

   (302)  true
                                                                                
      
Type: Boolean
                                                                                
        
Time: 0 sec
(303) -> Float has  ("^": (%, Fraction Integer) -> %)

   (303)  false
                                                                                
      
Type: Boolean
                                                                         
Time: 0.04 (OT) = 0.04 sec
(304) -> Float has  (^: (%, Fraction Integer) -> %)

   (304)  true


Can one unify Interpreter and Compiler and communicate clear (and unique
rules) for infix functions and escaping?



-- 
Mit freundlichen Grüßen

Johannes Grabmeier

Prof. Dr. Johannes Grabmeier
Köckstraße 1, D-94469 Deggendorf
Tel. +49-(0)-991-2979584, Tel. +49-(0)-151-681-70756
Tel. +49-(0)-991-3615-141 (d),  Fax: +49-(0)-32224-192688

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/37096524-0ca0-adaa-ba39-da6301796b8c%40grabmeier.net.

Reply via email to