Newbie Questions (psi, psl meaning, interfacing C and Ada)

140 views
Skip to first unread message

Olivier Henley

unread,
May 8, 2019, 7:23:27 PM5/8/19
to ParaSail Programming Language
Hi to all,

Today I read the reference manual 'in diagonal'. (I do not have time right now) but I did not find answers to these questions:

1. What is the meaning of .psl and .psi. What is their relation and purpose. A real world example would help (I think I get it, psi is probably ParaSail Interface, but psl... )

2. Is it possible to interface C? I think so, but because I read on this forum that the GTK examples are broken ... I can not test and wrap my head around how to do it. I am interested in testing just a small native windows API call, eg. mouse position and maybe report that on the command line. This would be the base for another quick and dirty tutorial. So can you point me a working and basic example?

3. While we are at it, how to interface Ada code? Any example, simple toy, working?

Thank you,

Olivier

Tucker Taft

unread,
May 8, 2019, 9:40:12 PM5/8/19
to ParaSail Programming Language
On Wed, May 8, 2019 at 7:23 PM Olivier Henley <olivier...@gmail.com> wrote:
Hi to all,

Today I read the reference manual 'in diagonal'. (I do not have time right now) but I did not find answers to these questions:

1. What is the meaning of .psl and .psi. What is their relation and purpose. A real world example would help (I think I get it, psi is probably ParaSail Interface, but psl... )

I chose filename extensions for files containing mostly interfaces (.psi), and files containing only implementation (.psl).  As far as acronyms, ".psi" stands for ParaSail Interfaces and ".psl" stands for "ParaSaiL".  In the GNAT Ada world, these would be ".ads" and "adb".  In the C world, these would be ".h" and ".c".  The ParaSail interpreter/compiler doesn't actually care, and you can put whatever you want in any source file.  It is really up to the users to obey a convention should they so please.

2. Is it possible to interface C? I think so, but because I read on this forum that the GTK examples are broken ... I can not test and wrap my head around how to do it. I am interested in testing just a small native windows API call, eg. mouse position and maybe report that on the command line. This would be the base for another quick and dirty tutorial. So can you point me a working and basic example?

The 8.0 version of ParaSail supports specifying the "convention" of a given operation implemented in some other language, and declared using "is import(#XXX, convention => #YYY)".  If you don't specify a convention, then by default it uses a ParaSail-specific mechanism which always passes three parameters, a pointer to a "context" record, a pointer to a list of parameters, and a pointer to a type descriptor.  You can see a bunch of routines that are implemented in Ada and use this ParaSail-specific mechanism in the file interpreter/psc-interpreter-builtins.adb.  Their ParaSail declarations appear in lib/aaa.psi.

If you specify "is import(#my_c_routine, #c)" it will pass the parameters using the "normal" C calling conventions, and not pass a "context" record nor a type descriptor.  We don't have any examples of such routines included in the release.  We'll try to put together some examples to illustrate this capability.


3. While we are at it, how to interface Ada code? Any example, simple toy, working?

As mentioned above, there are lots of examples of ParaSail code calling Ada, but essentially all of it uses the "ParaSail-specific" approach with the three parameters described above.  If you want to just pass the parameters, and no context nor type descriptor, it is essentially just like C, so you would use "is import(#my_ada_routine, #ada)"

We'll put together an example to show using this approach.

Thank you,

Olivier

Take care,
-Tuck

--
You received this message because you are subscribed to the Google Groups "ParaSail Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to parasail-programming...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/parasail-programming-language/cd44a12f-87ef-4280-8979-8f9039b505b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tucker Taft

unread,
May 8, 2019, 10:27:35 PM5/8/19
to ParaSail Programming Language
On Wed, May 8, 2019 at 9:39 PM Tucker Taft <tuc...@yaletaft.com> wrote:
...
The 8.0 version of ParaSail supports specifying the "convention" of a given operation implemented in some other language, and declared using "is import(#XXX, convention => #YYY)". 

Actual, the syntax is "is import(#name, #convention)" as illustrated below:
...

If you specify "is import(#my_c_routine, #c)" it will pass the parameters using the "normal" C calling conventions, and not pass a "context" record nor a type descriptor.  ...

-Tuck

Zing Chen

unread,
May 9, 2019, 12:10:55 AM5/9/19
to ParaSail Programming Language


On Thursday, May 9, 2019 at 6:23:27 AM UTC+7, Olivier Henley wrote:
......

3. While we are at it, how to interface Ada code? Any example, simple toy, working?

Thank you,

Olivier

You may want to look at procedure Basic_Array_Create in psc-interpreter-builtins.adb and the corresponding func Create of interface PSL::Containers::Basic_Array in aaa.psi.

I think it's pretty good example of doing the "tame" work in ParaSail and let Ada do the "wild" work. Or "safe" and "unsafe" code, if you'd like to compare ParaSail to some other languages.

Best,

Zing.

Olivier Henley

unread,
May 17, 2019, 7:20:28 PM5/17/19
to ParaSail Programming Language
Still trying to find my ways:

parasail_main.exe expr_tree.psl "../lib/aaa.psi" 

fails. expr_tree.psl:353:40: Error: Module var Countable not found:

I tried many naive fixes ... its always worst... so here I am reporting.

Thanks,

Olivier
 

Zing Chen

unread,
May 17, 2019, 7:59:37 PM5/17/19
to ParaSail Programming Language
I'd recommend using bin/interps.csh script to run the interpreter (parasail_main.exe). Likewise, for the compiler, bin/pslc.csh maybe easier to use than using compiler.exe directly.

Regards,

- Zing.

Vernon Brown

unread,
May 18, 2019, 12:31:12 AM5/18/19
to ParaSail Programming Language
I'm gonna guess you're running on Windows, probably in a Windows cmd console, not a csh or tcsh shell.
I created a one line Windows .bat file (named psli.bat) for running the interpreter from cmd:

@C:\parasail_release_8_0\bin\parasail_main.exe "C:\parasail_release_8_0\lib\aaa.psi" "C:\parasail_release_8_0\lib\reflection.psl" "C:\parasail_release_8_0\lib\reflection.psi" "C:\parasail_release_8_0\lib\psvm_debugging.psl" "C:\parasail_release_8_0\lib\debugger_console.psl" %*


This adds in the modules needed for the debugger as well.

I verified that your real problem is that "../lib/aaa.psi" must be the first module on the command line.  If you just switch the order, then you're command should work.  

Tucker Taft

unread,
May 19, 2019, 10:26:00 AM5/19/19
to ParaSail Programming Language
If you run parasail_main.exe directly (rather than using bin/interp.csh), you always have to give "lib/aaa.psi" as the first parameter.  lib/aaa.psi defines all of the basic modules of the language, and needs to precede the uses.  ParaSail allows some amount of forward reference, but there are still some limits, and in particular lib/aaa.psi defines some modules that are fundamental.

As suggested, the bin/interp.csh script tries to simplify the usage a bit, and is recommended.

Sorry for the difficulty.

Take care,
-Tuck

--
You received this message because you are subscribed to the Google Groups "ParaSail Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to parasail-programming...@googlegroups.com.

Olivier Henley

unread,
Feb 19, 2020, 8:44:45 AM2/19/20
to ParaSail Programming Language
New newbie questions :)

1. Parasail has no 'import module' mecanism yet, right? Is loading module definitions upfront at the compiler cmd the long term way to go? 

2. What is the prefered setup on windows to use csh? 

3. Is it possible/how to represent 'heterogeneous dictionaries' like an incomming json object?

    I ask because this is kind of bread and butter of current microservices communications practices and I suspect the huge success of Javascript and Python to be strongly coupled to the low friction one has to share 'communication objects'

Tucker Taft

unread,
Feb 19, 2020, 8:56:27 AM2/19/20
to ParaSail Programming Language
On Wed, Feb 19, 2020 at 8:44 AM Olivier Henley <olivier...@gmail.com> wrote:
New newbie questions :)

1. Parasail has no 'import module' mecanism yet, right? Is loading module definitions upfront at the compiler cmd the long term way to go? 

ParaSail does have an "import" but currently it can only import from modules that are included in the set of source files identified on the command line.  A directory search path would be an obvious enhancement, and this question will prompt me to give that a higher priority!

2. What is the prefered setup on windows to use csh? 

I personally use cygwin.


3. Is it possible/how to represent 'heterogeneous dictionaries' like an incomming json object?

There is no standard "json" parser, though you could certainly write one to read in a specific structure.  The notion of a general json parser that would produce the ParaSail type declaration automatically sounds like an interesting idea.  Python and Javascript are not statically-typed languages, so it is more straightforward for them.  But having a tool that could take a json file and generate the ParaSail declarations would make a lot of sense, coupled with a library for ultimately reading the same json file, or a json file using the same pattern.  Another good project... ;-)

    I ask because this is kind of bread and butter of current microservices communications practices and I suspect the huge success of Javascript and Python to be strongly coupled to the low friction one has to share 'communication objects'

Take care,
-Tuck

--
You received this message because you are subscribed to the Google Groups "ParaSail Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to parasail-programming...@googlegroups.com.

Tucker Taft

unread,
Feb 19, 2020, 10:31:11 AM2/19/20
to ParaSail Programming Language
On Wed, Feb 19, 2020 at 8:56 AM Tucker Taft <tuc...@yaletaft.com> wrote:
On Wed, Feb 19, 2020 at 8:44 AM Olivier Henley <olivier...@gmail.com> wrote:
...


3. Is it possible/how to represent 'heterogeneous dictionaries' like an incomming json object?

There is no standard "json" parser, though you could certainly write one to read in a specific structure.  The notion of a general json parser that would produce the ParaSail type declaration automatically sounds like an interesting idea.  Python and Javascript are not statically-typed languages, so it is more straightforward for them.  But having a tool that could take a json file and generate the ParaSail declarations would make a lot of sense, coupled with a library for ultimately reading the same json file, or a json file using the same pattern.  Another good project... ;-)

I suppose a more basic capability is to take an existing ParaSail object and stream it out in a JSON-compatible format.  That is actually a simpler place to start.  And presumably that capability would be reversible, so an object of the same type could be reconstructed from the JSON.  This kind of object streaming has been on our road map for quite a while, and again, your query justifies bumping up its priority.

...

-Tuck

Olivier Henley

unread,
Feb 19, 2020, 10:39:08 AM2/19/20
to ParaSail Programming Language
ParaSail does have an "import" but currently it can only import from modules that are included in the set of source files identified on the command line.  A directory search path would be an obvious enhancement, and this question will prompt me to give that a higher priority! 

Having to wrap a program call to arrange all dependencies and configuration is very flexible as it does not force limitations on how the program can/should be used.  If I understand correctly Golang felt a bit of heat from its 'import' mecanism. As stated here(https://blog.golang.org/using-go-modules), they are moving to a module system: "Go 1.11 and 1.12 include preliminary support for modules, Go’s new dependency management system that makes dependency version information explicit and easier to manage."

IMO better stay rudimentary but flexible than lock up with an 'incomplete' mecanism.

That said, Its good information to know when approaching the language; the intended way to arrange for dependencies. I know its totally unrelated to fundamental work but not knowing can be confusing on how to operate, test the basics etc.


2. What is the prefered setup on windows to use csh? 

I personally use cygwin.

Can you make the gtk examples fly? My real question: is linux more 'the' way to go around Parasail? Looks like it.


3. Is it possible/how to represent 'heterogeneous dictionaries' like an incomming json object?

There is no standard "json" parser, though you could certainly write one to read in a specific structure.  The notion of a general json parser that would produce the ParaSail type declaration automatically sounds like an interesting idea.  Python and Javascript are not statically-typed languages, so it is more straightforward for them.  But having a tool that could take a json file and generate the ParaSail declarations would make a lot of sense, coupled with a library for ultimately reading the same json file, or a json file using the same pattern.  Another good project... ;-)

    I ask because this is kind of bread and butter of current microservices communications practices and I suspect the huge success of Javascript and Python to be strongly coupled to the low friction one has to share 'communication objects'

Be it json, toml, yaml, etc it is always the same story, heterogeneous data structures of primitive types. Food for though, I bring back Golang as I think their 'sugar' is quite useful in the context of a statically typed language:

Given an incoming json object, eg. 'resp' the construction of 'r' is in place, or not. (only data right...)
The mapping for a given encoder (here json and bson, but it can be any other implementation provided) makes the deserialization automatic provided 'sourcing' tags.

type friend struct {
    name string `json:"nickname" bson:"nickname"`
}

var r struct {
    query []struct {
        uid   string `json:"id" bson:"id"`
        count int    `json:"count" bson:"count"`
        friends friend[] `json:"friends" bson:"friends"`
    } `json:"q" bson:"q"`
}

err = json.Unmarshal(resp.GetJson(), &r) 

Note, 'the tagging' gives the opportunity to rename a relation, eg. incoming is 'nickname: "olivier"` will end up, 'name: "olivier' on our side, in r.
Note also that any fields present in the source but not 'tagged' in the receiving struct will be skipped. Quite handy when interested in only a subset of what is comming in. 
Eg, when using the youtube api, json objects comming your way are monstruous, they just dump all the information they have about the 'thing' you asked. 

This contrasts a lot with languages that requires you to do the mapping 'by hand'.  
I think rust has some crates doing something similar.

A parser that generates the type declaration is useful but requires an extra step when dealing with third parties communicating json objects but not providing a reference schema. 
Most services just send you data, you inspect it, eg. postman, and code your receiving structures on the spot.

Ok, A+
Reply all
Reply to author
Forward
0 new messages