f



Context syntax proposals, using "with", withing "use" etc.

After watching for some time the prolonged dances around "with and use",
I'm inclined to contribute to the topic.

First, I'd like to say that all the arguments concerned with repeating of a
package's name aren't serious at all: as for extra typing, this is a matter
of a text editor, not of the language; and as for a possibility of mistake
(that is, placing an unintended package's name in "use"), it is a matter of
a style and a corresponding style checker compiler option - you have little
chance to get such a mistake unnoticed with a quite simple rule: for example,
always place "use" and "with" in the same line, and never mix different
packages in the same line (compiler can easily verify that).

Second, there is still a displeasure here, which can even become a hindrance
in some circumsrances: when there are many context clauses for a package,
they just occupy too big part of the text; and because those context clauses
are necessarily at the beginning of each package, they intersperse and clutter
the whole program, which makes reading more difficult (even if each package
has its own window) - if one tried not to study thoroughly, but just to read
and catch the general method\logic\approach of the program.

So my guess is that the real reasons demanding the changes for "with" and
"use", if any, aren't about repeated package names, but actually about overall
amount of the text in (all) context clauses (and exclusion of repeated package
names simply decreases this amount).

Therefore I think that explicit separatation of the whole context from the
package's specs as well as from the package's body would be much more
consistent and useful step (than all possible manipulation with "with" and
"use" only) for the purpose. I mean something like that:

  package MyDream context is
  -- or package context MyDream is  - if you like it better
    with ...;
    with ...; use ...;
    ...
  end MyDream;

  package MyDream is
    ...
  end MyDream;

  package body MyDream context is
    with ...;
    with ...; use ...;
    ...
  end MyDream;

  package body MyDream is
    ...
  end MyDream;


Certainly there may be other syntactic forms for that separation, and extra
keyword ("context") may be avoided... although it seems in place there.



Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia

0
aek6125 (179)
12/22/2003 11:53:13 PM
comp.lang.ada 8774 articles. 2 followers. Post Follow

1 Replies
601 Views

Similar Articles

[PageSpeed] 47

Alexandre E. Kopilovitch wrote:

> After watching for some time the prolonged dances around "with and use",
> I'm inclined to contribute to the topic.
 
[snip arguments]

To be honest, after about 2 or 3 weeks into learning Ada I have droped the
use of "use" inside the context alltogether. In fact a also dropped the use
of "use" in specifications as well.

I did this after finding two other features:

use type ...;

procedure Proc
is
    use ...;
begin
    ....
end Proc;

The reason was that it became very difficult for me to figure out where
which feature was provided, raising the learning curve significant.
Restricting the use of "use" as outlined above makes the programs a lot
easyer to read and it does un-clutter the context area as well.

So no need for change here.

With Regards

Martin

-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com

0
krischik (1357)
12/23/2003 10:37:01 AM
Reply:

Similar Artilces:

When to use "." and when to use "!"
I'm still confused about this and I can't find anywhere that explains it properly. I have the MS book "Access 2003" in front of me and I'm reading Part 5 about VB and so on. It's telling me about how to refer to a specific database and has the example:- Dim dbMyDb As DAO.Database Set dbMyDb = DBEngine.Workspaces(0).Databases(0) but, but, but, but - what do those dots (periods, full stops, call them what you will) mean? (OK, it appears to be the same usage as C/C++/Java when referring to class/structure members, but I wish it would tell me that somewhere) Why are there dots used in referring to object members in this case but when referring to controls on forms (for example) one uses "!". Surely there must be somewhere that helps one understand this basic syntax. -- Chris Green Generally, a dot exposes properties and methods and a bang (!) exposes members of a collection. So forms!frmMyForm.Visible refers to the visible property of frmMyForm, which is a member of the forms collection. What makes this harder (or easier, depending on your perspective) to grasp, is that Access has gotten more and more forgiving about using the "wrong" notation. usenet@isbd.co.uk wrote in news:44316bba.0@entanet: > I'm still confused about this and I can't find anywhere that explains > it properly. > > I have the MS book "Access 2003" in front of me and I'm reading Part 5 > about VB and so on....

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By chance I created a small program as follows: =========== s : string := "CAT"; procedure modify ( s1 : out string ) is begin s1(2) := 'U'; end modify; ... put ( modify(s) ); =========== now I get as a result "CUT", and i dont understand why i get this result. Doesnt the "out" specify that its initial value isnt passed in via the parameter? But it seems to be passed in the above. In fact the "out" is acting like an "in out". I am a little confused. Could someone shed some light on this? Many thanks! zork "zork" <zork@nospam.com> wrote in message news:4104d5de@dnews.tpgi.com.au... > Hi i found the following explaination: > > In Ada, "in" parameters are similar to C++ const parameters. They are > effectively read-only within the scope of the called subprogram. > Ada "in out&q...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

Urgent need """""""""""INFORMATICA DEVELOPER"""""""""""""
Hello Partners, How are you ? Please find the requirements below. Title: Database/ETL Developer Duration: 6 months Location: NY Exp: 7+ Locals preferred Database/ETL requirements (Mandatory) Candidate must have worked with financial instruments, preferably Mutual Funds but, Equities are also ok. PL/SQL - packages, Stored procs, Functions, Aggregate functions, Pipelined Functions Informatica 8.6 - especially complex mappings, complex maplets, complex workflows, transformations Oracle 10g/11g Unix/Linux shell scripting Database/ETL requirements (Optional) Data warehousing experience Threading and job concepts in 10g/11g Cost based Optimizer concepts in 10g/11g Must : Experience with XML files and partitioning concepts in Oracle, Collections, Material Views Note : No phone calls please. : send Resumes to karthik@bhaninfo.com Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

Invalid use of "." "!"
In writing a sql statement I get the error "invalid use of "." "!"......... this is apparently coming because the where clause of the sql statemt refers to a combo box with sales persons names in it. All the names are listed first initial followed by a "." and last name. I am assuming the error i am getting is coming from the "." in the combo box. How do I get around the invalid use of the "." ? Thanks Never mind..... didnt have enough quotation marks. "Learning" <texson552000@yahoo.com> wrote in message news:DQELg.10308$o42.364@tornado.texas.rr.com... > In writing a sql statement I get the error "invalid use of "." "!"......... > this is apparently coming because the where clause of the sql statemt refers > to a combo box with sales persons names in it. All the names are listed > first initial followed by a "." and last name. I am assuming the error i am > getting is coming from the "." in the combo box. > > How do I get around the invalid use of the "." ? > > Thanks > > ...

when should one use "and" and "or"
Hi All, just got hit w the ff > case > when x==1 or x==2 > print "yeoh!" > end SyntaxError: compile error (irb):17: syntax error, unexpected kOR, expecting kTHEN or ':' or '\n' or ';' when x==1 or x==2 ^ "or" and "and" both exhibit the behaviour in ruby1.8/1.9. workaround 1 put parens around the condition (not again) 2 replace or/and with ||/&& i believe there are other similar quirks when using "and/or".. has ruby relegated the use of "and/or"....? best regards -botp On Feb 4, 9:55=A0pm, botp <botp...@gmail.com> wrote: > Hi All, > > just got hit w the ff > > > case > > when x=3D=3D1 or x=3D=3D2 > > =A0 print "yeoh!" > > end x =3D 5 =3D=3D>5 case x when 2,3 p 'no' when 4,5 p 'yes' end "yes" =3D=3D>nil On Fri, Feb 5, 2010 at 1:45 PM, w_a_x_man <w_a_x_man@yahoo.com> wrote: #> x =3D 5 #> =A0 =A0=3D=3D>5 #> case x #> =A0when 2,3 #> =A0 =A0p 'no' #> =A0when 4,5 #> =A0 =A0p 'yes' #> end of course i know that ;-) im talking about the second type of "case", eg > case > when x.baz and y.foo .... best regards -botp botp wrote: > i believe there are other similar quirks when using "and/or".. > has ruby relegated the use ...

Use "range," not "for"?
Thanks to everyone who suggested ways to get a proc to recognize all variables in the global scope--here's why I wanted to know. (Maybe someone has done this better already--if so, don't hesitate to let me know!) I've found that a simple "foreach" loop fairly often won't do the jobs I want done, and I need to use "for"--ugh! Well, I recently read at least part of a book about Python. It didn't look like an improvement over Tcl for the most part, but it has at least a few good features, one of which is the "range" expression. I thought a "range" procedure in Tcl might be a good substitute for the clumsy "for." So, here's my first effort. Instead of writing this: for {set i 1} {$i<= 10} {incr i} {puts "$i. \"for\" is ugly!"} you can write this: range i 1 to 10 {puts "$i. \"range\" is beautiful!"} Or, if you have a list called "lum," instead of writing this: for {set i 0} {$i < [llength $lum]} {incr i} {puts [lindex $lum $i]} you can write this: range i 0 no [llength $lum] {puts [lindex $lum $i]} To go backward, skipping every other number, instead of this: for {set i 10} {$i >= 0} {incr i -2} {puts $i} you can write this: range i 10 to 0 -2 {puts $i} The usage is pretty obvious: "range var start cutoff end ?incr? body." In other words, (1) the word "range"; (2) a vari...

Using "fsolve": How to control iteration using "residuals" and "norm of step"??
Hello Everyone, I am using fsolve to solve a system of linear equations and it&#8217;s working fine. However, I have a coupe of issues: (i) Even when the solution (alpha) converges, I am getting the message to choose a new point. I am guessing that it has to do with &#8220;norm of step&#8221; as probably the code is trying a smaller step. I am using option like this: options = optimset('Jacobian','on', 'algorithm', 'Levenberg-Marquardt','Display','iter-detailed', 'MaxFunEvals', 10000, 'MaxIter', 10000,'TolX'...

"In" "Out" and "Trash"
I just bought a new computer and I re-installed Eudora Light on my new computer. But when I open Eudora, the "In", "Out" and "Trash" links are not on the left side of the screen the way they were on my old computer. How can I get these links back on the left side of the screen? Thank you. On 25 Mar 2007 09:49:22 -0700, "abx" <abfunex@yahoo.com> wrote: >I just bought a new computer and I re-installed Eudora Light on my new >computer. But when I open Eudora, the "In", "Out" and "Trash" links >are ...

Using "frame -container" and "-use" on Aqua
Hello Tclers, When using Tk 8.5.8 on Aqua, it is not possible to use "-use" to embed a window in a container frame that belongs to another process. X11 does not have this limitation. Is this a missing feature in Tk, or is it a limitation of Aqua or the Carbon framework? Keith. On 5/20/10 7:00 AM, Keith Nash wrote: > Hello Tclers, > > When using Tk 8.5.8 on Aqua, it is not possible to use "-use" to embed a > window in a container frame that belongs to another process. X11 does not > have this limitation. Is this a missing feature in Tk...

Strange behavior of "use if" (a conditional "use" with the if module)
I have a program with this line of code: use if( $Config{'osname'} =~ /Win/ ), 'Win32::Process::Info'; Perl complains: Too few arguments to `use if' (some code returning an empty list in list context?) at ... However, if I change the regex operator to !~ then Perl is quite happy (the only change is replacing the equals with a bang). Does anyone know why Perl is unhappy with =~ in my "use if" statement thanks! * David Filmer wrote in comp.lang.perl.misc: >I have a program with this line of code: > > use if( $Config{'osname'} =~ /Win/ ), 'Win32::Process::Info'; > >Perl complains: > >Too few arguments to `use if' (some code returning an empty list in list context?) at ... If your osname actually matches /Win/ then you probably forgot to load Config.pm. Otherwise, the expression returns an empty list, so there are no arguments passed, just like the error message says. Use something like `scalar($Config{'osname'} =~ /Win/)` to force a scalar context. -- Bj�rn H�hrmann � mailto:bjoern@hoehrmann.de � http://bjoern.hoehrmann.de Am Badedeich 7 � Telefon: +49(0)160/4415681 � http://www.bjoernsworld.de 25899 Dageb�ll � PGP Pub. KeyID: 0xA4357E78 � http://www.websitedev.de/ Quoth David Filmer <usenet@davidfilmer.com>: > I have a program with this line of code: > > use if( $Config{'osname'} =~ /Win/ ), 'Win32::Process::Info'...

When to use "INT" or "int"?
In windef.h there is a type definition typedef int INT; Windows itself uses both types. For example, in the declaration of SetSysColors: BOOL WINAPI SetSysColors( int cElements, // number of elements to change CONST INT *lpaElements, // address of array of elements CONST COLORREF *lpaRgbValues // address of array of RGB values ); Then I have a question: What is the consideration beneath the choice of using either "int" or "INT"? In this case, why cElements should better be declared as "int&...

"between" is using index but "like" is not
I have a table with a text column and I'd like to find entries matching "pattern*" in that column. When using a between i get: sd=> explain analyze select id,name, shortname from tr where shortname between 'Run_' and 'RunZ'; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Index Scan using tr_shortname_idx on traces (cost=0.00.....

Using "If" and "NDSolve" together
Hello! I have a tricky job to do: I want to simulate something, and want to assign a value to a variable under certain conditions. Those are, if time is within a certain interval, I want that variable to have that value. Otherwise, I want it to have other value. Until now, I have been trying to use the following command: Funcao[first_, last_] := Plot[A[t] /. NDSolve[ {A'[t] == k0 A0 - k1 A[t], B'[t] == k1 A[t] - k2 B[t], C'[t] == k2 B[t] - k3 C[t], A[0] == 2 10^-6, B[0] == 0, C[0] == 0} /. k0 -> 10^-2 /. k1 -> 10^-5 /. k2 -&g...

help with "timefmt" and "using"...
Hi, is it possible to plot a data file like the following fragment without rebuild the archive? #DATE TIME-BEG TIME-END VALUE 7/03/2001 15:15:00 16:15:00 40115 7/03/2001 16:15:00 17:15:00 39960 7/03/2001 17:15:00 18:15:00 39990 8/03/2001 09:15:00 10:15:00 39985 8/03/2001 10:15:00 11:15:00 39855 8/03/2001 11:15:00 12:15:00 40310 I need to use as X data the 1st and the 3th columns, Y the last. I've spent a lot of time to try but with no result... Thanks a lot!!! Ciao, Francesco. Francesco <odiolaspam@tin.it> wrote: > Hi, > is it possible to plot a data file like the following fragment > without rebuild the archive? Sort of. You'll have to filter the file, but you can do that on-the-fly if you're on Unix or something sufficiently like it: plot '< awk "{print $1,$3,$4}" datafile' using 1:3 For other than timefmt data, that wouldn't be so much of a hassle, but unfortunately, the strptime() function that is the bases of 'set timefmt' offers no way of ignoring parts of the input. -- Hans-Bernhard Broeker (broeker@physik.rwth-aachen.de) Even if all the snow were burnt, ashes would remain. On 23 Oct 2003 09:01:23 GMT, Hans-Bernhard Broeker <broeker@physik.rwth- aachen.de> wrote: > if you're on Unix or something sufficiently like it: > > plot '< awk "{print $1,$3,$4}" datafile' using 1:3 > > For other than timefmt data...

When to use "perror" and "fprintf"
Reading the man pages and some code did not really help me in understanding the difference between - or better when I should use - perror("...") and fprintf(stderr, "...") Any hint or help is appreciated. L. Westmeier "L. Westmeier" <westmeier@informatik.hu-berlin.de> wrote: > Reading the man pages and some code did not really help me in > understanding the difference between - or better when I should use - > perror("...") and fprintf(stderr, "...") They do rather different things. You use perror() to print a message to...

"my" suppresses "used only once" warnings
Here we see "my" suppresses "used only once" warnings. And I thought "my" was all good. $ perl -we 'use diagnostics; $g=1; my $h=2;' Name "main::g" used only once: possible typo at -e line 1 (#1) (W once) Typographical errors often show up as unique variable names. If you had a good reason for having a unique name, then just mention it again somehow to suppress the message. The our declaration is provided for this purpose. NOTE: This warning detects symbols that have been used only once so $c, @c, %c, *c, &c, sub c{...

Urgent JAVA Requirement in """"""NEW YORK"""""""""
Hello Partners, How are you ? Please find the requirement below. Location : NY Duration : 8 mnths Rate :Open Job description: Java/J2EE Web Service Developer =B7 (4+ years of application development experience in Java/J2EE and Web service technologies. =B7 Experience with spring & Hibernate. =B7 Experience with J2EE Application Server (preferably Web logic). =B7 Preferable Aqua logic DSP Experience =B7 Preferable Sonic ESB Composite Service experience Experience working in UNIX environment. Good working knowledge of Oracle RDBMS and PL/SQL) Note : Please send your updated resume along with contact no to Karthik@bhaninfo.com. Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com # 1572, 7 th Floor Suites, 1 Blue Hill Plaza Pearl River,NY-10965 www.bhaninfo.com ...

"proc report" using a "by" variable as an "across" variable
I didn't know that you could use a "by" variable as an "across" variable as well in proc report. I tried it out today just to see what syntax errors it would throw at me but instead it worked without complaint. I guess it's one of the things I should know but have never come across before. It is useful for putting what would normally be in a "by line" in the columns of a table instead. It looks better that way, sometimes. On Tue, 18 Oct 2005 04:38:07 -0700, RolandRB <rolandberry@HOTMAIL.COM> wrote: >I didn't know that you could use a "...

puts "\\".gsub("\\", "\\\\")
Hello, I have a mini-ruby quiz. Guess what this line of code writes to the console, then try it for yourself: puts "\\".gsub("\\", "\\\\") Why is that so? Martin From: martinus [mailto:martin.ankerl@gmail.com]=20 # Hello, I have a mini-ruby quiz. Guess what this line of code writes to # the console, then try it for yourself: # puts "\\".gsub("\\", "\\\\") puts "\\".gsub("\\", "\\\\") \ #=3D> nil # Why is that so? faq. escaping the escape in sub/gsub. search the archives. maybe you want somethin...

Gary Sokolich """"""
"""""""""" http://www.manta.com/c/mmlq5dm/w-gary-sokolich W Gary Sokolich 801 Kings Road Newport Beach, CA 92663-5715 (949) 650-5379 http://www.tbpe.state.tx.us/da/da022808.htm TEXAS BOARD OF PROFESSIONAL ENGINEERS February 28, 2008 Board Meeting Disciplinary Actions W. Gary Sokolich , Newport Beach, California �V File B-29812 - It was alleged that Dr. Sokolich unlawfully offered or attempted to practice engineering in Texas (...) Dr. Sokolich chose to end the proceedings by signing a Consent Order that was accepted by ...

Question about "sprintf" "@" "do for"
Hello, this works: A1=3D1 A2=3D2 A3=3D3 i=3D1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari i=3Di+1 vari=3Dsprintf("A%.f",i) print vari,"=3D",@vari do for [i=3D1:3]{ vari=3Dsprintf("A%.f",i) print vari } But I want to have "print vari,"=3D",@vari" in the loop. But it dosen't=20 work. Why can't I use "print vari,"=3D",@vari" in the loop? Is there a=20 solution for? J=C3=B6rg Jörg ...

Definition of "shall", "should", "must", etc.
Is there a written standard anywhere that defines specification terms like "shall" and "should" and "must"? I've run into a number of projects where, in particular, "shall" / "must" / "will" are all used interchangeably. Your thoughts... "C. J. Clegg" <reply.to.newsgroup@nospam.no> wrote in message news:jbsbh19g228ne84213f8kh0uvccj5ie6sg@4ax.com... > > Is there a written standard anywhere that defines specification terms > like "shall" and "should" and "must"? > > I've run into a number of projects where, in particular, "shall" / > "must" / "will" are all used interchangeably. > When in doubt, place an explicit statement that serves to indicate the interpretation that will be used (make certain it is not inconsistent with the customers rules and regulations) > Your thoughts... C. J. Clegg wrote: > Is there a written standard anywhere that defines specification terms > like "shall" and "should" and "must"? > > I've run into a number of projects where, in particular, "shall" / > "must" / "will" are all used interchangeably. > > Your thoughts... oh ...the beauty of google and having worked in telecomms where this knowledge is an (unfortunate) must (no pun intended) http://standards.ieee.org/guides/style/section...

Web resources about - Context syntax proposals, using "with", withing "use" etc. - comp.lang.ada

Resources last updated: 3/23/2016 5:44:23 AM