githwxi / ATS-Postiats

ATS2: Unleashing the Potentials of Types and Templates
www.ats-lang.org
Other
354 stars 54 forks source link

Where-expression Error #277

Closed edward70 closed 1 year ago

edward70 commented 1 year ago

I was reading the introduction https://ats-lang.sourceforge.net/DOCUMENT/INT2PROGINATS/HTML/x187.html and wrote this program:

val area =
  PI * radius * radius where {
  val PI = 3.14 and radius = 10.0 // simultaneous bindings
}

val _ = print (area)

implement main0 () = ()

I get the error:

In file included from 2_dats.c:15:
2_dats.c: In function ‘_057_home_057_edw_057_learnats_057_2_056_dats__dynload’:
2_dats.c:210:21: error: ‘PMVtmpltcstmat’ undeclared (first use in this function)
  210 | ATSINSmove(statmp1, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(ATSPMVf0loat(3.14), ATSPMVf0loat(10.0))) ;
      |                     ^~~~~~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
2_dats.c:210:21: note: each undeclared identifier is reported only once for each function it appears in
  210 | ATSINSmove(statmp1, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(ATSPMVf0loat(3.14), ATSPMVf0loat(10.0))) ;
      |                     ^~~~~~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
2_dats.c:210:39: error: ‘g0float_mul’ undeclared (first use in this function)
  210 | ATSINSmove(statmp1, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(ATSPMVf0loat(3.14), ATSPMVf0loat(10.0))) ;
      |                                       ^~~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
2_dats.c:210:51: warning: implicit declaration of function ‘S2Eextkind’ [-Wimplicit-function-declaration]
  210 | ATSINSmove(statmp1, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(ATSPMVf0loat(3.14), ATSPMVf0loat(10.0))) ;
      |                                                   ^~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
2_dats.c:210:62: error: expected expression before ‘atstype_double’
  210 | ATSINSmove(statmp1, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(ATSPMVf0loat(3.14), ATSPMVf0loat(10.0))) ;
      |                                                              ^~~~~~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
2_dats.c:210:78: error: expected expression before ‘)’ token
  210 | ATSINSmove(statmp1, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(ATSPMVf0loat(3.14), ATSPMVf0loat(10.0))) ;
      |                                                                              ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
2_dats.c:215:62: error: expected expression before ‘atstype_double’
  215 | ATSINSmove(statmp0, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(statmp1, ATSPMVf0loat(10.0))) ;
      |                                                              ^~~~~~~~~~~~~~
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~
2_dats.c:215:78: error: expected expression before ‘)’ token
  215 | ATSINSmove(statmp0, PMVtmpltcstmat[0](g0float_mul<S2Eextkind(atstype_double)>)(statmp1, ATSPMVf0loat(10.0))) ;
      |                                                                              ^
/usr/local/lib/ats2-postiats-0.4.2/ccomp/runtime/pats_ccomp_instrset.h:276:37: note: in definition of macro ‘ATSINSmove’
  276 | #define ATSINSmove(tmp, val) (tmp = val)
      |                                     ^~~

Please help me understand my mistake, I can't understand the error message.

hwxi commented 1 year ago

include "share/atspre_staload.hats"

You need the above line at the beginning (which tells the compiler where to find the default library).

edward70 commented 1 year ago

Thank you!