Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > Re: Maybe of in...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 21 of 27 Topic 1137 of 1247
Post > Topic >>

Re: Maybe of interest to people interested in programming languages?

by thomas.mertes@[EMAIL PROTECTED] May 27, 2008 at 07:24 AM

On 27 Mai, 14:00, Friedrich Dominicus <just-for-news-fr...@[EMAIL PROTECTED]
> wrote:
> thomas.mer...@[EMAIL PROTECTED]
 writes:
>
> > The syntax descriptions of the top and bottom condition versions
> > are:
>
> >   $ syntax expr: .loop.until.().do.().end.loop is -> 25;
> >   $ syntax expr: .loop.().until.().do.end.loop is -> 25;
>
> Well I have problem understanding this, I've read the example but to
> not get it, would you mind to explain it a bit?

Maybe you should download Seed7 and to try it.
If there are problems I will try my very best to help you.
A commented version of the chkloop.sd7 program is:

  $ include "seed7_05.s7i"; # Include the Seed7 definitions.

  (**
   *  The following declaration defines the syntax of the 'loop'
   *  statement. The syntax description is between : and 'is'. The
   *  symbols 'loop', 'until', 'do', 'end' and 'loop' are keywords
   *  used by the 'loop' statement. With () the place for an
   *  expression is described. At the syntax level it can be any
   *  expression (the semantic level checks for the types of
   *  expressions afterwards). With -> the associativity is defined
   *  as left to right binding of the parameters. This is essential
   *  for operators where a+b+c can be interpreted as (a+b)+c (which
   *  is 'left to right' or -> ) or as a+(b+c) (which is 'right to
   *  left' or <- ). In the case of the 'loop' statement the
   *  associativity is irrelevant. Finally 25 denotes the priority
   *  of the 'loop' statement. Aggain this is relevant for
   *  operators. By convention Seed7 defines statements with
   *  priority 25. Syntax declarations are described here:
   *  http://seed7.sourceforge.net/manual/syntax.htm
   *)
  $ syntax expr: .loop.().until.().do.().end.loop is -> 25;

  (**
   *  The following declaration defines the semantic of the 'loop'
   *  statement. The 'loop' statement is defined as function
   *  (The type 'proc' means: A function which returns 'void').
   *  The name of the function is between 'proc:' and 'is func'.
   *  The keywords ('loop', 'until', 'do', 'end', 'loop') and the
   *  parameters are in the same sequence as in the syntax
   *  definition. The parameters 'ref proc: statements1',
   *  'ref func boolean: condition' and 'ref proc: statements2' are
   *  closures which are evaluated in the function body at runtime.
   *  After the symbol 'local' the boolean local variable
   *  'exitLoop' is defined and initialized with FALSE.
   *  The actual implementation of the 'loop' statement uses
   *  a 'repeat' statement and an 'if' statement to provide the
   *  necessary functionality. The closure parameters get
   *  expressions (of type 'proc' and type 'func boolean') as actual
   *  parameters. The closure parameters are evaluated when they
   *  are used in the function body. The 'exitLoop' variable takes
   *  care that the condition is not evaluated too often (it might
   *  have side effects). Another example which defines a statement
   *  is here: http://seed7.sourceforge.net/examples/declstat.htm
   *)
  const proc: loop
                (ref proc: statements1)
              until (ref func boolean: condition) do
                (ref proc: statements2)
              end loop is func
    local
      var boolean: exitLoop is FALSE;
    begin
      repeat
        statements1;
        if not condition then
          statements2;
        else
          exitLoop := TRUE;
        end if;
      until exitLoop;
    end func;

  (** This is the 'main' function of the chkloop.sd7 example. By
   *  convention all Seed7 programs have a 'main' function which
   *  is used to start the execution of the program. The local
   *  integer variable is used to terminate the loop. The 'loop'
   *  statement is aggain written according to the syntax rules.
   *  The actual parameters for the three closures are
   *  'writeln("stat1 " <& number)' for 'statements1',
   *  'number = 0' for 'condition' and
   *  'writeln("stat2 " <& number); decr(number)' for 'statements2'.
   *)
  const proc: main is func
    local
      var integer: number is 10;
    begin
      loop
        writeln("stat1 " <& number);
      until number = 0 do
        writeln("stat2 " <& number);
        decr(number);
      end loop;
    end func;

You can copy this program to the file 'chkloop.sd7' and start
it with:

  hi chkloop

Then it will write the following output:

tm@[EMAIL PROTECTED]
 hi chkloop
HI INTERPRETER Version 4.5.3992  Copyright (c) 1990-2008 Thomas Mertes
   259 syntax.s7i
  3446 seed7_05.s7i
    82 chkloop.sd7
  3787 lines total
378700 lines per second
1625019 bytes
stat1 10
stat2 10
stat1 9
stat2 9
stat1 8
stat2 8
stat1 7
stat2 7
stat1 6
stat2 6
stat1 5
stat2 5
stat1 4
stat2 4
stat1 3
stat2 3
stat1 2
stat2 2
stat1 1
stat2 1
stat1 0

> Type inference has been suggested for Seed7 also. My answer to this
> > is here:http://seed7.sourceforge.net/faq.htm#type_inference
>
> >> I'm strictly against the currently way of doing threading as in C/C++
> >> etc. It's too complex to get right IMHO and I'd prefer some Erlang
> >> kind way of doing this everytime. For my taste this seems even better
> >> be suited for object oriented programming. And object should not be
> >> tampered with from all edged of the program. Read somewhere about
that
> >> Threads can be considered the GOTOS of current programming.
> >> IMHO debuggability and maintainability can just be put aside with
> >> Threads.
>
> > Here I am with you. OTOH I would like to cover this area with Seed7.
>
> I guess we are not the only ones, but definitly the minority. If one
> sees how that is handled in C/C++ even Java or C# one can feel the
> programms grinding to a squeaking halt ;-) or mayb just a silent
> deadlock ;_)

:-)
I will have to think over a concept for threading in the future,
but currently I am busy with other things.

> > BTW. I do not suggest that you should not implement Q and use Seed7
> > instead. What I propose is:
>
> No it's just that I'm wondering if it might be of interest.
>
> > You can define functionality you would like for Q in Seed7.
> > That additional functionality could be gathered in a library.
> > The 'loop' statement, statements which sup****t DBC, some containers
> > and more could be defined in this library.
>
> Well that would mean a "radical" rewrite. And I can not see the
> "value" in it but curiosity. Howerver I've overlooked a few other
> language and found more than one near what we intended with
> Q. Examples are Ocaml, even Haskell, Io, Smalltalk and Common Lisp
> and one may or may not believe it but Eiffel has moved into that
> direction. And boy all the alternatives run circles on their hands
> around Q, for functionality, usability....
>
> > If there are conflicts between Q and Seed7 functionality there
> > could be also a more radical solution. Seed7 is defined in the
> > "seed7_05.s7i" include file. You could replace that with "q_1.s7i".
> > The 'hi' interpreter would boot from that file and provide the Q
> > functionality.
>
> Yes I guess that would not be the worst think to use a programmable
> programming language

At least the basic idea of Seed7 (actually of its predecessor) was
to make it usable as some sort of meta progamming language (or as
you said a programmable programming language). I already described
this ideas elsethread.

If you have questions, just ask.
I am happy with every feedback.

Greetings Thomas Mertes

Seed7 Homepage:  http://seed7.sourceforge.net
Seed7 - The extensible programming language: User defined statements
and operators, abstract data types, templates without special
syntax, OO with interfaces and multiple dispatch, statically typed,
interpreted or compiled, ****table, runs under linux/unix/windows.
 




 27 Posts in Topic:
Maybe of interest to people interested in programming languages?
Friedrich Dominicus <j  2008-04-25 08:08:03 
Re: Maybe of interest to people interested in programming langua
Marco <prenom_nomus@[E  2008-05-09 06:23:32 
Re: Maybe of interest to people interested in programming langua
Marco <prenom_nomus@[E  2008-05-09 07:49:46 
Re: Maybe of interest to people interested in programming langua
Friedrich Dominicus <j  2008-05-18 17:30:37 
Re: Maybe of interest to people interested in programming langua
scholz.lothar@[EMAIL PROT  2008-05-22 04:45:01 
Re: Maybe of interest to people interested in programming langua
"Bartc" <bc@  2008-05-24 20:28:55 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-23 07:37:28 
Re: Maybe of interest to people interested in programming langua
scholz.lothar@[EMAIL PROT  2008-05-23 10:36:54 
Re: Maybe of interest to people interested in programming langua
Friedrich Dominicus <j  2008-05-26 17:46:08 
Re: Maybe of interest to people interested in programming langua
"Bartc" <bc@  2008-05-26 20:17:55 
Re: Maybe of interest to people interested in programming langua
Friedrich Dominicus <j  2008-05-27 07:13:33 
Re: Maybe of interest to people interested in programming langua
"Bartc" <bc@  2008-05-27 09:40:47 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-23 12:25:09 
Re: Maybe of interest to people interested in programming langua
scholz.lothar@[EMAIL PROT  2008-05-24 00:34:09 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-24 04:23:50 
Re: Maybe of interest to people interested in programming langua
scholz.lothar@[EMAIL PROT  2008-05-24 05:52:03 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-26 01:20:43 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-26 23:32:51 
Re: Maybe of interest to people interested in programming langua
Friedrich Dominicus <j  2008-05-27 14:00:39 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-26 23:49:31 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-27 07:24:13 
Re: Maybe of interest to people interested in programming langua
Friedrich Dominicus <j  2008-05-30 14:01:17 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-05-30 13:00:26 
Re: Maybe of interest to people interested in programming langua
Friedrich Dominicus <j  2008-05-31 10:57:17 
Re: Maybe of interest to people interested in programming langua
Walter Banks <walter@[  2008-05-31 05:54:04 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-06-02 08:59:07 
Re: Maybe of interest to people interested in programming langua
thomas.mertes@[EMAIL PROT  2008-06-03 04:59:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 15:59:52 CDT 2008.