comp.lang.ada
 help / color / mirror / Atom feed
From: Ivan Levashew <octagram@bluebottle.com>
Subject: Re: Creating and using Ada packages: need refinement
Date: Sun, 30 Mar 2008 18:11:42 +0700
Date: 2008-03-30T18:11:42+07:00	[thread overview]
Message-ID: <fsnsh5$8bt$1@registered.motzarella.org> (raw)
In-Reply-To: <70f327d6-5a7a-4118-8871-ad35e7528c2d@e23g2000prf.googlegroups.com>

> Not affiliated with Pegasoft or BUSH, but have always liked the idea
> of an Ada based shell scripting language for Ada people.

Yes, I had an idea of Ada-like scripting *SHELL* language. But I'm not 
satisfied with BUSH.

I have reviewed BUSH documentation.

http://www.pegasoft.ca/docs/bushtutorial.html#2.1

> => v := (2*3 + 5)/2
> => (Assuming v is a new universal_numeric variable)
> => ? v
>  5.50000000000000E+00
a surprise
Being and Ada programmer I would expect it to be integer.
Delphi has separate "/" and "div" operators for integer and floating 
point division. Ada has only one "/". I'm unhappy with the fact that "/" 
defaults to the floating point result here.

http://www.adaic.com/standards/05rm/html/RM-3-3-2.html
> The named number denotes a value of type universal_integer if the 
> type of the static_expression is an integer type. The named number 
> denotes a value of type universal_real if the type of the 
> static_expression is a real type.
I'd like "v := (2*3 + 5)/2" in BUSH behave the same way as
"v : constant := (2*3 + 5)/2" in Ada, but constantcy.
How many times did you need to deal with float types in the shell 
script? I can't remember a one. So it's better to require explicit 
typecasts here. There must be separate universal float and integer. 
Integers are not just subset of Floats.

http://www.pegasoft.ca/docs/bushtutorial.html#2.3
> The format of the SQL command, including how quoting is used, is
> determined by the database being used. BUSH will not perform file
> globbing (otherwise select count(*) would give very strange
> results!). BUSH will substitute variables with dollar sign expansion
> and the output from SQL commands can be redirected like an operating
> system command. For this reason you'll have to escape characters
> like ">" with a backslash used with SQL on the command line.
> 
> => select * from test where name \> 'c'
a pitfall
What's the difference between C's if (a = 0) {...
and BUSH's ... name > 'c' ?
I'd better choose another syntax for redirection.
Or maybe make parser a bit smarter?
=> select * from test where name > 'c' > filename
I don't know SQL, but "> filename" looks like being unable to introduce 
ambiguities. OK, I know, it's not a good solution. What else can we do? 
Let's think...

=> select * from test where name > 'c' 1> filename
It is much better, isn't it? Just require everybody to write whitespaces 
around ">", "<", etc. in SQL. Normal programmers write them anyway.

> -- export DISPLAY only if it exists
> DISPLAY : string := "undefined";
> pragma unchecked_import( shell, DISPLAY );
> if DISPLAY /= "undefined" then
>   pragma export( shell, DISPLAY );
> end if;
a dirty trick



http://www.pegasoft.ca/docs/bushref.html#3.7
All the types are lowercased. It is OK in an interactive prompt, but 
it's ugly IMO in full-sized scripts. I'd like to dupe every type in 
Mixed_Case. Or maybe let types be case-insensitive. A bit inconsistent 
but... It's not beautiful.


I'm using bash for a long time. I had some wishes regarding shell 
capabilities :
1. Directories as a first-order objects.
I'd like to write something like

=> zzz_src := tgz.extract (directory.open ("xxx/yyy/zzz.tgz"))
=> zzz_image := zzz_src.configure
=> zzz_image.make
=> zzz_destroot := zzz_image.install
=> directory.save (zzz_destroot, "~/zzz_destroot")
And let the shell take care of cleaning intermediate results: zzz_image 
was not bound to anything.
I'd like to use projects the same way. Projects are not neccessarily 
just one directory. I mean extension projects.

2. Downwards shell closures.
Shell closure is a special program like this:
#!/usr/bin/closure /var/shell-ipc/xxx 112312
Where /var/shell-ipc/xxx is a socket and 112312 is a shell closure 
identifier. Shell must create these temporary closures on demand.

I have no clear model of relationships between "internal" and "external" 
objects. Internal objects are like zzz_image. They exist somewhere but 
are not bound to any location. After they lose the last reference, they 
are subject to deletion. I thought about 'Location attribute for 
internal objects. In order to allow external utilities to deal with 
internal objects we must either "save" it to some location or deal with 
it in situ, by its current location. Downwards shell closure can't be 
saved. (It will be a continuation this way). It is usable only during 
its lifetime so one must use 'Location. 'Location will create temporary 
executable closure stub:

declare
    procedure CC_Wrapper (...) is
    begin
       ...
    end CC_Wrapper;
begin
    zzz_image := zzz_src.configure (CC => CC_Wrapper'Location);
    zzz_image.make;
end;

3. Make capabilities.
bash calls make, make calls bash, bash calls make...

One must remember the rules of escaping and quoting. Simple sequences 
without loops look the same way as they are in bash, but loops must be
written with '; \'. $() works different ways in make and bash.

build:
   for arch in $$ARCHS uni; do \
     mkdir -p Intermediate/out/$$arch; \
     mkdir -p Intermediate/out/$$arch/lib/pkgconfig; \
     cp -r Input/darwin-pkgs/ Intermediate/out/$$arch/lib/pkgconfig/; \
     ln -s "$$SDK"/* Intermediate/out/$$arch/; \
   done
   for i in Frozen/* ; do \
     ln -s ../"$$i" Intermediate/"$${i:7}" ; \
   done

Piece of my environment.
I think make is better be extension of shell. Make is usable in many 
ways, not just for compilation.

Once again:
=> zzz_src := tgz.extract (...)
=> zzz_image := zzz_src.configure
=> zzz_image.make
=> zzz_destroot := zzz_image.install
It looks make-ish, isn't it? What was make initially created for? To 
avoid recompilations and recomputations. It's a kind of optimization. I 
think it could be implemented in the scope of shell scripting. I would 
like all the gprbuild capabilities to be incorporated into the shell.

I need some time to formalize it.

-- 
If you want to get to the top, you have to start at the bottom



  reply	other threads:[~2008-03-30 11:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14 19:09 Creating and using Ada packages: need refinement Ivan Levashew
2008-03-15  0:32 ` Georg Bauhaus
2008-03-15  2:50   ` Ivan Levashew
2008-03-15 17:10     ` Simon Wright
2008-03-15 18:26       ` Ivan Levashew
2008-03-15 22:55         ` Ludovic Brenta
2008-03-16  1:52           ` Ivan Levashew
2008-03-26  9:30           ` Ivan Levashew
2008-03-26 10:37             ` Ludovic Brenta
2008-03-26 15:43               ` Ivan Levashew
2008-03-26 20:30                 ` Ludovic Brenta
2008-03-28 12:00                   ` Ivan Levashew
2008-03-28 15:31                     ` Eric Hughes
2008-03-28 15:51                     ` Georg Bauhaus
2008-03-28 19:06                     ` Steve Whalen
2008-03-30 11:11                       ` Ivan Levashew [this message]
2008-03-31 19:04                         ` Steve Whalen
2008-03-26 10:44             ` Georg Bauhaus
2008-03-26 15:32               ` Ivan Levashew
2008-03-26 15:48                 ` Ivan Levashew
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox