variables in load paths

66 views
Skip to first unread message

Brandon Barker

unread,
Dec 10, 2014, 12:19:00 PM12/10/14
to ats-lan...@googlegroups.com
Sorry if it has been asked before, I will try to update the approrpiate docs as needed. If you have something like:

staload JNI = "{$JNI}/SATS/jni.sats"

How do you set $JNI? Environment variables seems to not be the answer.


Hongwei Xi

unread,
Dec 10, 2014, 12:33:37 PM12/10/14
to ats-lan...@googlegroups.com
You can set it as follows:

#define JNI_targetloc "$PATSHOMERELOC/contrib/JNI"


--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/10bef205-098c-48c0-85ba-f07b0ab6f76b%40googlegroups.com.

Brandon Barker

unread,
Dec 10, 2014, 12:55:10 PM12/10/14
to ats-lan...@googlegroups.com
I defined this in e.g Gradle/Calculator.dats (trying several permutations of fulling expanding $PATSHOMERELOC and setting within %{^ %}) to no avail.
Message has been deleted

gmhwxi

unread,
Dec 10, 2014, 12:57:22 PM12/10/14
to ats-lan...@googlegroups.com

You can also do it this way:

patsopt -DATS JNI_targetloc=\"${JNI}\" ...

if you set JNI as an environment variable.

Brandon Barker

unread,
Dec 10, 2014, 12:57:28 PM12/10/14
to ats-lan...@googlegroups.com
Oh, maybe I need to use atspkgreloc... 

gmhwxi

unread,
Dec 10, 2014, 1:05:19 PM12/10/14
to ats-lan...@googlegroups.com
Maybe PATSHOMERELOC was not properly set.


On Wednesday, December 10, 2014 12:55:10 PM UTC-5, Brandon Barker wrote:

Brandon Barker

unread,
Dec 10, 2014, 1:12:24 PM12/10/14
to ats-lang-users
It seems to be correct in the environment:

echo $PATSHOMERELOC 
/home/brandon/ATS-Postiats-contrib


gmhwxi

unread,
Dec 10, 2014, 1:18:46 PM12/10/14
to ats-lan...@googlegroups.com
If you paste your code here, then we should be able to find out.

Brandon Barker

unread,
Dec 10, 2014, 1:24:30 PM12/10/14
to ats-lan...@googlegroups.com
I tried this one too, but it seems to be the same (I have attached the file):

brandon@brandon-OEM ~/ATS-Postiats-contrib/projects/SMALL/Calculator/Gradle $ echo $JNI
/home/brandon/ATS-Postiats-contrib/contrib/JNI
brandon@brandon
-OEM ~/ATS-Postiats-contrib/projects/SMALL/Calculator/Gradle $ patsopt -DATS JNI_targetloc=\"${JNI}\" -d Calculator.dats  | grep JNI
/home/brandon/ATS-Postiats-contrib/contrib/JNI/SATS/jni.sats: 249(line=15, offs=1) -- 284(line=17, offs=3)
#include "JNI/CATS/jni.cats"
ATSdyncst_mac(atscntrb_JNI_GetStringUTFChars)
ATSdyncst_mac(atscntrb_JNI_ReleaseStringUTFChars)
ATSdyncst_mac(atscntrb_JNI_RaiseExceptionByClassName)
ATSINSflab(__patsflab_JNI_eval):
ATSINSmove(tmp960, atscntrb_JNI_GetStringUTFChars(arg0, arg2)) ;
ATSINSmove_void(tmp962, atscntrb_JNI_ReleaseStringUTFChars(arg0, arg2, tmp960)) ;
ATSINSmove_void(tmp964, atscntrb_JNI_RaiseExceptionByClassName(arg0, ATSPMVstring("java/lang/IllegalArgumentException"), ATSPMVstring("ParsingError"))) ;


Calculator.dats
Calculator_dats.c

Hongwei Xi

unread,
Dec 10, 2014, 1:29:51 PM12/10/14
to ats-lan...@googlegroups.com
If you can already generate *_dats.c, it means the following line worked:


staload JNI = "{$JNI}/SATS/jni.sats"

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.

gmhwxi

unread,
Dec 10, 2014, 1:44:32 PM12/10/14
to ats-lan...@googlegroups.com
I tried your source code and encountered no problems.

By the way, JNI_targetloc is already defined in share/atspre_define.hats:

https://github.com/githwxi/ATS-Postiats/blob/master/share/atspre_define.hats

There is no need to define it again unless your new definition is different.


On Wednesday, December 10, 2014 1:29:51 PM UTC-5, gmhwxi wrote:
If you can already generate *_dats.c, it means the following line worked:

staload JNI = "{$JNI}/SATS/jni.sats"

Brandon Barker

unread,
Dec 10, 2014, 1:53:46 PM12/10/14
to ats-lang-users
I think I may have spotted a problem but need to step out for a few minutes:

  "${INCLUDE} -IIATS ${PATSHOME}/contrib -I${JNIincl} -c Calculator.dats"
} // end of [Calculator_dats_o]

I think it should be reloc; do you have a symlink there to ATS-contrib/contrib?

--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.

gmhwxi

unread,
Dec 10, 2014, 2:02:13 PM12/10/14
to ats-lan...@googlegroups.com
You got it :)

Please change PATSHOME to PATSHOMERELOC.

In my setting, these two are the same.

gmhwxi

unread,
Dec 10, 2014, 2:07:16 PM12/10/14
to ats-lan...@googlegroups.com
FYI. I have fixed it in the Github.

Brandon Barker

unread,
Jan 19, 2015, 1:10:46 PM1/19/15
to ats-lang-users
I seem to be having a bit of trouble with this mechanism still. The #define works (commented out now), but the command line option shown below must not be quite right:

brand_000@bbsurfacepro3 ~
$ patscc -DATS UNSAFE_targetloc="/home/brand_000/ATS-Postiats/prelude/SATS" hello.dats
patsopt: error(0): the command-line argument [UNSAFE_targetloc=/home/brand_000/ATS-Postiats/prelude/SATS] cannot be properly parsed.
exit(ATS): uncaught exception: _2home_2brand_000_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)

brand_000@bbsurfacepro3 ~
$ patscc -DATS UNSAFE_targetloc=\"/home/brand_000/ATS-Postiats/prelude/SATS\" hello.dats
patsopt: error(0): the command-line argument [UNSAFE_targetloc=/home/brand_000/ATS-Postiats/prelude/SATS] cannot be properly parsed.
exit(ATS): uncaught exception: _2home_2brand_000_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)


//#define UNSAFE_targetloc "$PATSHOME/prelude/SATS"

staload UN = "{$UNSAFE}/unsafe.sats"

implement
main0 () = {
  val x = $UN.cast2size(7)
  val () = println! ("{$UNSAFE}")
  val () = println! ("Hello world!") // English
  val () = println! x
} (* end of [main0] *)



On Wed, Dec 10, 2014 at 12:56 PM, gmhwxi <gmh...@gmail.com> wrote:
You can also do it this way

patsopt -DATS JNI_targetloc=\"${JNI}\" ...

if you set JNI is as an environment variable.


On Wednesday, December 10, 2014 12:33:37 PM UTC-5, gmhwxi wrote:

Hongwei Xi

unread,
Jan 19, 2015, 1:44:50 PM1/19/15
to ats-lan...@googlegroups.com
Try:


patscc -DATS UNSAFE_targetloc=\\\"/home/brand_000/ATS-Postiats/prelude/SATS\\\" hello.dats

Brandon Barker

unread,
Jan 19, 2015, 1:53:50 PM1/19/15
to ats-lang-users
Ah yes, this strange cygwin quoting issue again. I'll make a note on the wiki which I'll hopefully find in case I forget again.
Thanks!

Yannick Duchêne

unread,
Dec 27, 2015, 5:57:07 PM12/27/15
to ats-lang-users


Le mercredi 10 décembre 2014 18:33:37 UTC+1, gmhwxi a écrit :
You can set it as follows:

#define JNI_targetloc "$PATSHOMERELOC/contrib/JNI"


I have three related questions.

Are underscore formally allowed in path variable names? No path variable use any underscore in the distribution nor in contrib, so I wonder.

What explicitly if a variable is unknown? it is to be left as is or it is to be substituted an empty string?

Are substitutions to be recursive?

I know I could play with patscc to test, this is just that i prefer authoritative answers.

gmhwxi

unread,
Dec 27, 2015, 10:36:57 PM12/27/15
to ats-lang-users
1. The character '_' can be used in path names
2. Say you use $FOO but FOO is not defined (or defined as a non-string), the $FOO changes to FOO.
3. Recursive substitution is not supported (it can be easily supported if needed).

Yannick Duchêne

unread,
Dec 28, 2015, 2:26:44 AM12/28/15
to ats-lang-users


Le lundi 28 décembre 2015 04:36:57 UTC+1, gmhwxi a écrit :
1. The character '_' can be used in path names
Path variable names, I assume.
 
2. Say you use $FOO but FOO is not defined (or defined as a non-string), the $FOO changes to FOO.
Okay.
 
3. Recursive substitution is not supported (it can be easily supported if needed).

 That's OK, not an issue. This is just for a tool which needs to be able to locate file the same way Postiats do, and it was worth to ask for documentation too.

gmhwxi

unread,
Dec 29, 2015, 10:30:35 AM12/29/15
to ats-lang-users

I changed the implementation a bit to support recursive substitution;
the maximal recursion depth is set to be 100.
Reply all
Reply to author
Forward
0 new messages