seed7-users Mailing List for Seed7 (Page 9)
Interpreter and compiler for the Seed7 programming language.
Brought to you by:
thomas_mertes
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
|
Feb
(9) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
|
Sep
(4) |
Oct
(4) |
Nov
|
Dec
(1) |
2011 |
Jan
(2) |
Feb
|
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
(2) |
Aug
(6) |
Sep
(7) |
Oct
(3) |
Nov
(10) |
Dec
(4) |
2013 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(1) |
Dec
(1) |
2015 |
Jan
(2) |
Feb
(2) |
Mar
(2) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(3) |
Dec
|
2016 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(3) |
Dec
(3) |
2021 |
Jan
(2) |
Feb
(6) |
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
|
Aug
(1) |
Sep
(12) |
Oct
(4) |
Nov
(17) |
Dec
(3) |
2022 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(2) |
May
|
Jun
(17) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
(1) |
Mar
(4) |
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
2024 |
Jan
|
Feb
(5) |
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
(12) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2025 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Thomas M. <tho...@gm...> - 2012-04-23 08:01:39
|
On Fri, 20 Apr 2012 00:14:36 +0200, mok-kong shen <mok...@t-...> wrote: > Hallo, > > I am a newcomer of the list and wish to know: Is it possible to somehow > obtain in seed7 the functionality akin to e.g. that of SystemRandom of > Python? Do you mean an access to the random number generator of the operating system? AFAICS Python does not guarantee that SystemRandom is available on all operating systems. Seed7 tries to provide APIs that are always available. Besides this problem it would be possible to support such functionality. As quick solution for Linux you could just open "/dev/urandom" and obtain the random values from there. I am not a Python expert. Does SystemRandom plug in its functionality to the standard random function? Is there a class for random generators and SystemRandom is just one of them? The random function of Seed7 (rand) has currently no possibility to plug in a random number generator backend (but this extension could be done). It would also be possible to introduce a randomGenerator interface as backend for 'rand'. In this case there could be a built-in and a system random number generator. The Seed7 function 'rand' is overloaded for many types. Creating an extra function for system random values would also make it necessary to overload it for many types. Therefore I had the idea with a random number generator backend. Probably Python or other languages already have it. I was just too lazy to check. If you are interested in the Seed7 implementation of rand you can look at the function uint_rand in int_rtl.c which is used as hardcoded random number generator backend. The functions intRand, fltRand and bigRand are based on uint_rand. Does this answer your question? 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, portable, runs under linux/unix/windows. -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a |
From: mok-kong s. <mok...@t-...> - 2012-04-19 22:14:44
|
Hallo, I am a newcomer of the list and wish to know: Is it possible to somehow obtain in seed7 the functionality akin to e.g. that of SystemRandom of Python? Thanks in advance. M. K. Shen |
From: Leonardo C. <leo...@gm...> - 2011-12-09 08:03:54
|
Hi. Can an interface be implemented by integers? The following code works great in the intepreter but fails to compile using the translator to C: [code] $ include "seed7_05.s7i" ; const type: printable is new interface; const proc: print_this (in printable param) is DYNAMIC; const proc: print_this (in integer: p) is func begin noop; end func; type_implements_interface (integer, printable); const proc: main is func begin noop; end func; [/code] This is the output: [code] C>hi test_translator.sd7 ..\bin\hi test_translator.sd7 HI INTERPRETER Version 4.5.8882 Copyright (c) 1990-2011 Thomas Mertes C>hi comp.sd7 test_translator.sd7 ..\bin\hi ..\prg\comp.sd7 test_translator.sd7 HI INTERPRETER Version 4.5.8882 Copyright (c) 1990-2011 Thomas Mertes Compiling the compiler ... SEED7 COMPILER Version 2.0 Copyright (c) 1990-2011 Thomas Mertes Source: test_translator.sd7 Compiling the program ... Generating code ... after walk_const_list 622 13484928 94 optimizations done 57 evaluations done Calling the C compiler ... gcc -w -c tmp_test_translator.c 2>tmp_test_translator.cerrs *** Errors in "tmp_test_translator.c" - see "tmp_test_translator.cerrs" C>type tmp_test_translator.cerrs type tmp_test_translator.cerrs test_translator.sd7: In function 'o_1026_print_this': test_translator.sd7:4:1: error: incompatible type for argument 1 of 'o_1028_print_this' test_translator.sd7:6:25: note: expected 'inttype' but argument is of type 'struct rtlStructstruct' [/code] Thanks to keep up this project! |
From: Milo M. <mm...@ym...> - 2011-03-20 14:28:04
|
Thank you very much for that additional information. As per said information, I have created a patch for the Linux makefile which does two things: 1. It changes how the paths for the library files in the "depend" target are found: it uses a set of variables which, by default, allow for an installation to /usr/share/seed7/ and /usr/bin/hi. (This can be easily reset to the default behavior by specifying "BASE_DIR=`pwd`/.." on the command line for the "depend" target.) 2. It allows for a system-wide installation, into /usr/bin/hi and /usr/share/seed7, through the standard "install" target, which is accompanied by an "uninstall" target. Here is the patch, in unified format: --- a/seed7/src/mk_linux.mak 2011-03-06 05:51:35.000000000 -0500 +++ b/seed7/src/mk_linux.mak 2011-03-20 10:12:23.000000000 -0400 @@ -2,8 +2,12 @@ # To compile use a command shell and call: # make -f mk_linux.mak depend # make -f mk_linux.mak +# To install use a command shell and call: +# make -f mk_linux.mak install # If you are under windows you should use MinGW with mk_mingw.mak, mk_nmake.mak or mk_msys.mak instead. +DESTDIR = +prefix = /usr # CFLAGS = # CFLAGS = -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith # CFLAGS = -O2 -fomit-frame-pointer -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith @@ -25,6 +29,12 @@ LIBS = -lX11 -lncurses -lm # LIBS = -lX11 -lncurses -lm -lgmp # LIBS = -lX11 -lncurses -lm_p -lc_p +BIN_DIR = $(prefix)/bin +BASE_DIR = $(prefix)/share/seed7 +LIB_DIR = $(BASE_DIR)/lib +RLIB_DIR = $(BASE_DIR)/bin +DOC_DIR = $(BASE_DIR)/doc +PRG_DIR = $(BASE_DIR)/prg SEED7_LIB = seed7_05.a COMP_DATA_LIB = s7_data.a COMPILER_LIB = s7_comp.a @@ -116,6 +126,19 @@ clean: rm -f *.o ../bin/*.a depend a_depend b_depend c_depend version.h +install: ../bin/hi + mkdir -p $(DESTDIR)$(BIN_DIR) $(DESTDIR)$(RLIB_DIR) $(DESTDIR)$(LIB_DIR) $(DESTDIR)$(DOC_DIR) $(DESTDIR)$(PRG_DIR) + cp ../bin/hi $(DESTDIR)$(BIN_DIR)/hi + cp -t $(DESTDIR)$(RLIB_DIR) ../bin/*.a + cp -t $(DESTDIR)$(DOC_DIR) ../doc/* + cp -t $(DESTDIR)$(LIB_DIR) ../lib/*.s7i + cp -t $(DESTDIR)$(PRG_DIR) ../prg/* + rm $(DESTDIR)$(PRG_DIR)/hi + +uninstall: + rm -r $(BASEDIR) + rm $(prefix)/bin/hi + dep: depend strip: @@ -165,10 +188,10 @@ echo "#define LINKER_OPT_OUTPUT_FILE \"-o \"" >> version.h echo "#define LINKER_FLAGS \"$(LDFLAGS)\"" >> version.h echo "#define SYSTEM_LIBS \"$(LIBS)\"" >> version.h - cd ../bin; echo "#define SEED7_LIB \"`pwd`/$(SEED7_LIB)\"" >> ../src/version.h; cd ../src - cd ../bin; echo "#define COMP_DATA_LIB \"`pwd`/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd ../src - cd ../bin; echo "#define COMPILER_LIB \"`pwd`/$(COMPILER_LIB)\"" >> ../src/version.h; cd ../src - cd ../lib; echo "#define SEED7_LIBRARY \"`pwd`\"" >> ../src/version.h; cd ../src + cd ../bin; echo "#define SEED7_LIB \"$(RLIB_DIR)/$(SEED7_LIB)\"" >> ../src/version.h; cd ../src + cd ../bin; echo "#define COMP_DATA_LIB \"$(RLIB_DIR)/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd ../src + cd ../bin; echo "#define COMPILER_LIB \"$(RLIB_DIR)/$(COMPILER_LIB)\"" >> ../src/version.h; cd ../src + cd ../lib; echo "#define SEED7_LIBRARY \"$(LIB_DIR)\"" >> ../src/version.h; cd ../src depend: a_depend b_depend c_depend version.h $(CC) $(CFLAGS) -M $(SRC) > depend I have included this patch in the Seed7 AUR package at http://aur.archlinux.org/packages.php?ID=47584 and it is automatically applied before compilation. I have installed it on my own computer and it appears to work perfectly. Also, this patch could in theory be used to make packages for other Linux distros which use APT or RPM, but neither I nor my employer use them. Note, however, that the AUR isn't called a "User Repository" for nothing: it technically doesn't store the binary packages themselves, but bash scripts called "PKGBUILDS" which are sourced by the "makepkg" program to compile and make an actual package which the user can then install to their own system. The AUR includes a voting system, and packages with sufficient votes and popularity may be inducted into the "community" repository, which consists of binary packages which are maintained by a staff which is somewhat more loosely-knit than the regular package maintainers. You can read more about Arch Linux's packaging system at their excellent wiki (https://wiki.archlinux.org/index.php/AUR). This patch probably could be modified to work for the cygwin makefile as well, because cygwin also uses a UNIX-like file hierarchy standard. Once again, thank you very much for all your help. --- On Sun, 3/20/11, Thomas Mertes <tho...@gm...> wrote: > From: Thomas Mertes <tho...@gm...> > Subject: Re: [Seed7-users] Library search path > To: see...@li... > Cc: mm...@ym... > Date: Sunday, March 20, 2011, 10:03 AM > At Sat, 19 Mar 2011 15:52:01 +0000 > "Milo Mirate" <mm...@ym...> > wrote: > > This sounds great. I needed those details because I > would like to make an > > Arch Linux User Repository (http://aur.archlinux.org) package of Seed7 and > > I needed to know where to put the library files. Now > that I know how to > > specify where the interpreter should look for the > standard library, I can > > start making the package. Thank you again for your > help. > > Great, a package for Seed7. Thanks in advance. > Considering this case I try give you more precise > information. > > There are two things to consider: Seed7 include files (they > use > the extension .s7i and are sometimes called libraries in > the Seed7 > documentation) and Seed7 runtime libraries (static *.a > libraries of > the operating system). I suggest using different > directories for > *.s7i and *.a files. The position of all this files is > determined > in the makefile (and must be considered in a package). > > To determine the position of the *.a runtime libraries > (seed7_05.a, > s7_data.a and s7_comp.a) the preprocessor macros > SEED7_LIB, > COMP_DATA_LIB and COMPILER_LIB are written to the file > "version.h". > The commands in the makefile to do this are: > > cd ../bin; echo "#define SEED7_LIB > \"`pwd`/$(SEED7_LIB)\"" >> ../src/version.h; cd > ../src > cd ../bin; echo "#define COMP_DATA_LIB > \"`pwd`/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd > ../src > cd ../bin; echo "#define COMPILER_LIB > \"`pwd`/$(COMPILER_LIB)\"" >> ../src/version.h; cd > ../src > > The position of the Seed7 *.s7i include files is > determinated with > the preprocessor macro SEED7_LIBRARY (also written to > "version.h"). > The command to write SEED7_LIBRARY in the makefile is: > > cd ../lib; echo "#define SEED7_LIBRARY \"`pwd`\"" > >> ../src/version.h; cd ../src > > The file "version.h" is created with the 'make depend' > command. > My "version.h" file contains the following lines > (regarding > library and include files): > > #define SEED7_LIB "/home/tm/seed7_5/bin/seed7_05.a" > #define COMP_DATA_LIB "/home/tm/seed7_5/bin/s7_data.a" > #define COMPILER_LIB "/home/tm/seed7_5/bin/s7_comp.a" > #define SEED7_LIBRARY "/home/tm/seed7_5/lib" > > The mechanism to carry this and other information to the > Seed7 > compiler (comp.s7i) is as follows. The function > cmdConfigValue() > (see: "cmd_rtl.c") allows access to several values from > the > "version.h" file. BTW: The contents of the file > "version.h" > are described in "seed7/src/read_me.txt". > > Please do NOT change "version.h" manually. It contains many > things > that are determined automatically by the make process. If > you > want to change preprocessor macros in "version.h" you > should > definitely change the makefile. > > The Seed7 compiler needs detailed information about the C > compiler > and its runtime library. This information is created with > 'make depend' and written to "version.h". When the Seed7 > compiler > runs this information is obtained via cmdConfigValue(). > > There are two C compilers and runtime libraries to > consider: > > 1. The one which compiles the Seed7 interpreter and > the Seed7 > libraries (C compiler and runtime > used to crate the package). > 2. The one which is used by the Seed7 compiler (C > compiler > and runtime installed at a users > computer). > > As long as essentially the same C compiler and runtime > library is > used for both cases no unpleasant surprise will happen. > > For its own libraries Seed7 uses static (*.a) libraries. I > did not > try to uses dynamic (*.so) libraries for them. So I cannot > tell if > it would work for dynamic libraries. > > If you need more help or want some upstream changes, please > tell me. > > > 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, portable, runs under > linux/unix/windows. > > -- > GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit > gratis Handy-Flat! http://portal.gmx.net/de/go/dsl > |
From: Thomas M. <tho...@gm...> - 2011-03-20 10:03:17
|
At Sat, 19 Mar 2011 15:52:01 +0000 "Milo Mirate" <mm...@ym...> wrote: > This sounds great. I needed those details because I would like to make an > Arch Linux User Repository (http://aur.archlinux.org) package of Seed7 and > I needed to know where to put the library files. Now that I know how to > specify where the interpreter should look for the standard library, I can > start making the package. Thank you again for your help. Great, a package for Seed7. Thanks in advance. Considering this case I try give you more precise information. There are two things to consider: Seed7 include files (they use the extension .s7i and are sometimes called libraries in the Seed7 documentation) and Seed7 runtime libraries (static *.a libraries of the operating system). I suggest using different directories for *.s7i and *.a files. The position of all this files is determined in the makefile (and must be considered in a package). To determine the position of the *.a runtime libraries (seed7_05.a, s7_data.a and s7_comp.a) the preprocessor macros SEED7_LIB, COMP_DATA_LIB and COMPILER_LIB are written to the file "version.h". The commands in the makefile to do this are: cd ../bin; echo "#define SEED7_LIB \"`pwd`/$(SEED7_LIB)\"" >> ../src/version.h; cd ../src cd ../bin; echo "#define COMP_DATA_LIB \"`pwd`/$(COMP_DATA_LIB)\"" >> ../src/version.h; cd ../src cd ../bin; echo "#define COMPILER_LIB \"`pwd`/$(COMPILER_LIB)\"" >> ../src/version.h; cd ../src The position of the Seed7 *.s7i include files is determinated with the preprocessor macro SEED7_LIBRARY (also written to "version.h"). The command to write SEED7_LIBRARY in the makefile is: cd ../lib; echo "#define SEED7_LIBRARY \"`pwd`\"" >> ../src/version.h; cd ../src The file "version.h" is created with the 'make depend' command. My "version.h" file contains the following lines (regarding library and include files): #define SEED7_LIB "/home/tm/seed7_5/bin/seed7_05.a" #define COMP_DATA_LIB "/home/tm/seed7_5/bin/s7_data.a" #define COMPILER_LIB "/home/tm/seed7_5/bin/s7_comp.a" #define SEED7_LIBRARY "/home/tm/seed7_5/lib" The mechanism to carry this and other information to the Seed7 compiler (comp.s7i) is as follows. The function cmdConfigValue() (see: "cmd_rtl.c") allows access to several values from the "version.h" file. BTW: The contents of the file "version.h" are described in "seed7/src/read_me.txt". Please do NOT change "version.h" manually. It contains many things that are determined automatically by the make process. If you want to change preprocessor macros in "version.h" you should definitely change the makefile. The Seed7 compiler needs detailed information about the C compiler and its runtime library. This information is created with 'make depend' and written to "version.h". When the Seed7 compiler runs this information is obtained via cmdConfigValue(). There are two C compilers and runtime libraries to consider: 1. The one which compiles the Seed7 interpreter and the Seed7 libraries (C compiler and runtime used to crate the package). 2. The one which is used by the Seed7 compiler (C compiler and runtime installed at a users computer). As long as essentially the same C compiler and runtime library is used for both cases no unpleasant surprise will happen. For its own libraries Seed7 uses static (*.a) libraries. I did not try to uses dynamic (*.so) libraries for them. So I cannot tell if it would work for dynamic libraries. If you need more help or want some upstream changes, please tell me. 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, portable, runs under linux/unix/windows. -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl |
From: Milo M. <mm...@ym...> - 2011-03-19 15:52:11
|
This sounds great. I needed those details because I would like to make an Arch Linux User Repository (http://aur.archlinux.org) package of Seed7 and I needed to know where to put the library files. Now that I know how to specify where the interpreter should look for the standard library, I can start making the package. Thank you again for your help. -----Original Message----- From: "Thomas Mertes" <tho...@gm...> Date: Sat, 19 Mar 2011 09:29:45 To: <see...@li...> Cc: <mm...@ym...> Subject: Re: [Seed7-users] Library search path At 2011-03-18 20:43 "Thomas Mertes" <tho...@gm...> wrote: > ... The hardcoded > library directory described in paragraph 2 is determined in the > corresponding makefile and in "seed7/src/infile.c". To be more precise: The various makefiles write a line, which defines the preprocessor variable SEED7_LIBRARY, to the file "seed7/src/version.h". In my case the file "version.h" contains the line: #define SEED7_LIBRARY "/home/tm/seed7_5/lib" This preprocessor macro is used by the function init_lib_path() which is defined in the file "seed7/src/infile.c". The statements handling the hardcoded library directory start after the line #ifdef SEED7_LIBRARY The C string from SEED7_LIBRARY is converted to a Seed7 string with cstri_to_stri(). The function stri_to_path() converts the string to the standard path representation of Seed7. Finally the path is appended to the library search list (lib_path) with: append_to_lib_path(path, err_info) Note that there is also some debugging code written for the case that the macro SEED7_LIBRARY is not defined (after #else). Currently the macro SEED7_LIBRARY is always defined so this code is never executed. I plan to put there real code to handle the binary release of Seed7. The idea is: Use the path of the current executable to search for the library (include) directory. This is a little bit complex, because 3 cases must be taken into account: - The interpreter reads (analyses) a program: The absolute path of the 'hi' interpreter can be used to find the library (include) directory. - The compiler is interpeted and reads (analyses) a program: The absolute path of the 'hi' interpreter or the absolute path of the compiler source can be used to find the library (include) directory. - The compiler was compiled and reads (analyses) a program: The absolute path of the compiler executable can be used to find the library (include) directory. I wrote some functions to support getting the absolute path of an executable or Seed7 program: getProgramPath() (see: cmd_rtl.c) getArgv() (see: arr_rtl.c) getExecutablePath() (see: cmd_unx.c and cmd_win.c) examineSearchPath() (see: arr_rtl.c) What do you think about that? 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, portable, runs under linux/unix/windows. -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl |
From: Thomas M. <tho...@gm...> - 2011-03-19 08:29:53
|
At 2011-03-18 20:43 "Thomas Mertes" <tho...@gm...> wrote: > ... The hardcoded > library directory described in paragraph 2 is determined in the > corresponding makefile and in "seed7/src/infile.c". To be more precise: The various makefiles write a line, which defines the preprocessor variable SEED7_LIBRARY, to the file "seed7/src/version.h". In my case the file "version.h" contains the line: #define SEED7_LIBRARY "/home/tm/seed7_5/lib" This preprocessor macro is used by the function init_lib_path() which is defined in the file "seed7/src/infile.c". The statements handling the hardcoded library directory start after the line #ifdef SEED7_LIBRARY The C string from SEED7_LIBRARY is converted to a Seed7 string with cstri_to_stri(). The function stri_to_path() converts the string to the standard path representation of Seed7. Finally the path is appended to the library search list (lib_path) with: append_to_lib_path(path, err_info) Note that there is also some debugging code written for the case that the macro SEED7_LIBRARY is not defined (after #else). Currently the macro SEED7_LIBRARY is always defined so this code is never executed. I plan to put there real code to handle the binary release of Seed7. The idea is: Use the path of the current executable to search for the library (include) directory. This is a little bit complex, because 3 cases must be taken into account: - The interpreter reads (analyses) a program: The absolute path of the 'hi' interpreter can be used to find the library (include) directory. - The compiler is interpeted and reads (analyses) a program: The absolute path of the 'hi' interpreter or the absolute path of the compiler source can be used to find the library (include) directory. - The compiler was compiled and reads (analyses) a program: The absolute path of the compiler executable can be used to find the library (include) directory. I wrote some functions to support getting the absolute path of an executable or Seed7 program: getProgramPath() (see: cmd_rtl.c) getArgv() (see: arr_rtl.c) getExecutablePath() (see: cmd_unx.c and cmd_win.c) examineSearchPath() (see: arr_rtl.c) What do you think about that? 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, portable, runs under linux/unix/windows. -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl |
From: Thomas M. <tho...@gm...> - 2011-03-18 20:43:52
|
At Fri, 18 Mar 2011 14:02:13 +0000"Milo Mirate" <mm...@ym...> wrote: > The new FAQ entry explains it very well, thank you. The only question I > have is how to set the path in method 2 when compiling. There is not a method 2. The 4 numbered paragraphs describe in which directories the search for an include file happens. The hardcoded library directory described in paragraph 2 is determined in the corresponding makefile and in "seed7/src/infile.c". Interpreter and compiler use the same strategy to search for an include file. BTW.: I have improved the FAQ. Please take a look at http://seed7.sourceforge.net/faq.htm#lib_path and tell me your opinion about it. Interpreter and compiler may have problems to find the include directory in two situations: 1. The directory "seed7/lib" was move to a different place after the Seed7 interpreter was compiled. 2. The binary release of Seed7 is used and the current working directory is not "seed7/prg". In both cases the problem can be solved with the environment variable SEED7_LIBRARY. Just set SEED7_LIBRARY to the path of the directory containing the include/library files (without surrounding quotes). E.g.: /home/abc/seed7/lib How to set an environment variable depends on the operating system and shell (see: http://en.wikipedia.org/wiki/Environment_variable ). Currently there is a restriction for the environment variable SEED7_LIBRARY: The path must consist of ASCII characters (LATIN-1 characters might work also, but I have not tested it). 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, portable, runs under linux/unix/windows. -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl |
From: Milo M. <mm...@ym...> - 2011-03-18 14:30:59
|
The new FAQ entry explains it very well, thank you. The only question I have is how to set the path in method 2 when compiling. -----Original Message----- From: "Thomas Mertes" <tho...@gm...> Date: Fri, 18 Mar 2011 14:31:26 To: <see...@li...> Cc: <mm...@ym...> Subject: Re: [Seed7-users] Library search path At Thu, 17 Mar 2011 13:53:36 -0700 (PDT) Milo Mirate <mm...@ym...> wrote: > Where does the Seed7 interpreter look for libraries to load (from the > "include" statement) and how does one set this option? > I'm sorry if this is a somewhat stupid question. This is NOT a stupid question. I just searched the documentation and I found no good explanation concerning the Seed7 library search path. Therefore I added an FAQ about your question. See: http://seed7.sourceforge.net/faq.htm#lib_path The content of the this FAQ follows: Where does the Seed7 interpreter look for include files / libraries? ==================================================================== Include libraries with absolut path (an absolute path starts with a forward slash) are only searched at the specified place. All other include libraries are searched in several directories. This is done according to the Seed7 library search path. The following directories are in the library search path: 1. The directory of the source file. 2. The hardcoded library directory of the interpreter (an absolute path like "/directory_where_Seed7_was_installed/seed7/lib"). The hardcoded library directory is determined when the interpreter is compiled. So it only exists when the interpreter was compiled from source. The interpreter from the binary release uses a different strategy: When the path to the current program ends with "prg" it is replaced with "lib" and added to the library search path. E.g.: When "seed7/prg/hello.sd7" is interpreted the include files are searched in "seed7/lib". 3. The directory specified with the SEED7_LIBRARY environment variable. 4. Directories specified in the source file with the library pragma. E.g. a line like: $ library "/home/tm/seed7/lib" Seed7 compiler (comp.s7i) and interpreter use the same library search path. They will find Seed7 include files automatically, when Seed7 was compiled from source code. The interpreter from the binary release will only find library include files when programs from the "seed7/prg" directory are interpreted. To interpret programs from other directories with the binary interpreter it is necessary to set the environment variable SEED7_LIBRARY to the absolute path "/directory_where_Seed7_was_installed/seed7/lib". ----------------------- [ End of citation ] ----------------------- Hopefully that helps. If you have questions or sugestions, please tell me. 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, portable, runs under linux/unix/windows. -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl |
From: Thomas M. <tho...@gm...> - 2011-03-18 13:31:35
|
At Thu, 17 Mar 2011 13:53:36 -0700 (PDT) Milo Mirate <mm...@ym...> wrote: > Where does the Seed7 interpreter look for libraries to load (from the > "include" statement) and how does one set this option? > I'm sorry if this is a somewhat stupid question. This is NOT a stupid question. I just searched the documentation and I found no good explanation concerning the Seed7 library search path. Therefore I added an FAQ about your question. See: http://seed7.sourceforge.net/faq.htm#lib_path The content of the this FAQ follows: Where does the Seed7 interpreter look for include files / libraries? ==================================================================== Include libraries with absolut path (an absolute path starts with a forward slash) are only searched at the specified place. All other include libraries are searched in several directories. This is done according to the Seed7 library search path. The following directories are in the library search path: 1. The directory of the source file. 2. The hardcoded library directory of the interpreter (an absolute path like "/directory_where_Seed7_was_installed/seed7/lib"). The hardcoded library directory is determined when the interpreter is compiled. So it only exists when the interpreter was compiled from source. The interpreter from the binary release uses a different strategy: When the path to the current program ends with "prg" it is replaced with "lib" and added to the library search path. E.g.: When "seed7/prg/hello.sd7" is interpreted the include files are searched in "seed7/lib". 3. The directory specified with the SEED7_LIBRARY environment variable. 4. Directories specified in the source file with the library pragma. E.g. a line like: $ library "/home/tm/seed7/lib" Seed7 compiler (comp.s7i) and interpreter use the same library search path. They will find Seed7 include files automatically, when Seed7 was compiled from source code. The interpreter from the binary release will only find library include files when programs from the "seed7/prg" directory are interpreted. To interpret programs from other directories with the binary interpreter it is necessary to set the environment variable SEED7_LIBRARY to the absolute path "/directory_where_Seed7_was_installed/seed7/lib". ----------------------- [ End of citation ] ----------------------- Hopefully that helps. If you have questions or sugestions, please tell me. 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, portable, runs under linux/unix/windows. -- GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit gratis Handy-Flat! http://portal.gmx.net/de/go/dsl |
From: Milo M. <mm...@ym...> - 2011-03-17 20:53:43
|
Where does the Seed7 interpreter look for libraries to load (from the "include" statement) and how does one set this option? I'm sorry if this is a somewhat stupid question. |
From: Thomas M. <tho...@gm...> - 2011-01-07 09:37:56
|
On Mon, 3 Jan 2011 10:44:13 +0100, "Achim Rogalski" <po...@24...> wrote: > For a first test I have copied the Hello World Programm in a .sd7 file. > > On the seed7-homepage I could read that mk_mingw.mak together with > ming32-make is nessessary > for the Comand line window. > But before I have to compile the interpreter. I guess that you already downloaded a Seed7 *.tgz package and that a 'seed7' directory is somewhere on your computer now. > So I select the src folder where the mk_mingw.mak file exist. And then ? > What have I to do to see "Hello World" ? The 'src' folder contains the file 'read_me.text'. This file contains instructions to compile the interpreter. The chapter 'COMPILING UNDER WINDOWS WITH GCC' describes what to do: When gcc and mingw32-make from MinGW are installed use a console, go to the 'src' directory and type: copy mk_mingw.mak makefile mingw32-make depend mingw32-make If you do several compilation attempts in succession you need to do mingw32-make clean before you start a new attempt. When the compilation succeeds hi.exe is copied into the 'prg' directory. You can go to the 'prg' directory and type: hi hello This should write hello world A comprehensive test of the 'hi' interpreter can be done in the 'prg' directory with the command: hi chk_all This should write something like: HI INTERPRETER Version 4.5.6809 Copyright (c) 1990-2010 Thomas Mertes 262 syntax.s7i 3715 seed7_05.s7i 130 utf8.s7i 131 shell.s7i 294 chk_all.sd7 4532 lines total 226600 lines per second 2130634 bytes compiling the compiler - okay chkint - okay chkstr - okay chkprc - okay chkbig - okay chkbool - okay chkset - okay chkexc - okay Compiling a Seed7 program can be done e.g. with: hi comp hello This produces the executable 'hello.exe'. Executables produced by the Seed7 compiler can be used anywhere, since they are statically linked (no Seed7 dll required). BTW: I released also a binary version for windows, which contains already a compiled interpreter. See: http://sourceforge.net/projects/seed7/files/bin/ When you succeed in compiling the Seed7 interpreter you should prefer your compiled version over the binary version. The binary version uses relative paths to configure the Seed7 compiler. When you compile the Seed7 interpreter yourself the Seed7 compiler is configured with absolute paths (which usually is better unless you move the Seed7 directory around afterwards). 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, portable, runs under linux/unix/windows. -- Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief! Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail |
From: Achim R. <po...@24...> - 2011-01-03 10:03:39
|
For a first test I have copied the Hello World Programm in a .sd7 file. On the seed7-homepage I could read that mk_mingw.mak together with ming32-make is nessessary for the Comand line window. But before I have to compile the interpreter. So I select the src folder where the mk_mingw.mak file exist. And then ? What have I to do to see "Hello World" ? (in...@24...) |
From: Thomas M. <tho...@gm...> - 2008-12-02 20:19:24
|
Hello, I am writing a chapter about the structured syntax definition of Seed7. It would be nice to get some feedback about it before the final release. Here is it (read it with a monospaced font): 9. STRUCTURED SYNTAX DEFINITION =============================== Many languages have predefined constructs like statements and operators. This constructs have fixed syntax and semantics. A natural language or some meta language is used to describe the syntax and semantics of the constructs. Mostly the programmers are not allowed to define new syntactic constructs. But sometimes a full description of the syntax and semantics of a construct written in the programming language itself is helpful. This avoids the need to use ambiguous natural language descriptions and it is also unnecessary to learn an additional meta language. A formal description of new constructs in the language itself gives also the opportunity to define new constructs. Note that a compiler-compiler does not offer this opportunity and has also a meta language. There are different notations to specify the syntax of programming languages. The syntax statements of Seed7 use a notation called Seed7 Structured Syntax Description (abbreviated with S7SSD). The Backus-Naur Form (BNF) and its variants like the Extended Backus-Naur Form (EBNF) are another example of such a syntax specification. Since it is easier to understand new concepts when they are compared to well known concepts, the EBNF will be used as base to explain the S7SSD. 9.1 The Extended Backus-Naur Form As the name says the Extended Backus-Naur Form is an extension of the BNF. The extensions allow the definition of repetitions and optional parts without the use of recursive definitons. The EBNF has the following elements: - Nonterminal symbols consist of lower case letters and underline characters. - Terminal symbols are quoted strings or names in upper case characters which describe unprintable characters (control characters). - The concatenation of nonterminal and/or terminal symbols is described by writing them in sequence. - With | two alternatives can be separated. - Expressions of the extended Backus-Naur form can be put under parenthesis. - When a subexpression is optional it is enclosed in squared brackets [ ... ] . - When a subexpression may be omitted or repeated it is enclosed in curly braces { ... } . The syntax of the extended Backus-Naur form can be described with extended Backus-Naur form. syntax_description ::= { statement } . statement ::= identifier '::=' expression '.' . expression ::= term { '|' term } . term ::= factor factor . factor ::= identifier | string | '(' expression ')' | '[' expression ']' | '{' expression '}' . 9.2 The syntax of a statement To explain the Seed7 Structured Syntax Description we propose that a new statement, the 'loop' statement, should be defined. A 'loop' statement is similar to 'while' and 'repeat' loops but instead of having the conditional exit at the beginning or at the end it's conditional exit is in the middle of the loop. This middle conditional exit is part of the 'loop' statement. Therefore it should not be confused with the 'exit' statement that exists in some programming languages. An example of the 'loop' statement is: loop ch := getc(inFile); until ch = '\n' do stri &:= str(ch); end loop; An equivalent solution without the usage of the 'loop' statement would be: repeat ch := getc(inFile); if ch <> '\n' then stri &:= str(ch); end if; until ch = '\n'; The S7SSD of the 'loop' statement is: $ syntax expr: .loop.().until.().do.().end.loop is -> 25; For now we concentrate at the heart of the S7SSD, the expression: .loop.().until.().do.().end.loop For the purpose of the syntax description we can just remove the dots, which gives: loop () until () do () end loop With EBNF the 'loop' statement can be described as: loop_statement ::= 'loop' statement 'until' expression 'do' statement 'end' 'loop' . An EBNF description may use many nonterminal symbols such as 'statement' or 'expression'. The S7SSD does not distinguish between different nonterminal symbols. Instead the S7SSD only knows one nonterminal symbol: () Therefore the S7SSD cannot distinguish between 'statement', 'expression' or something else. At the syntax level any kind of expression can by substituted for a S7SSD nonterminal symbol (). With EBNF it is possible to describe constraints such as the type of an expression. The S7SSD relies on semantic checks to verify such constraints. An expression like loop 35 until 1+2 do integer end loop would be legal given the S7SSD of the 'loop' statement: $ syntax expr: .loop.().until.().do.().end.loop is -> 25; The definition of the semantic of the 'loop' statement is: const proc: loop (in proc: statements1) until (ref func boolean: condition) do (in 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 semantic definition determines which types are accepted between the keywords. For the 'loop' example with the semantic errors (see above) you would get an error message like: *** chkloop.sd7(35):51: Match for {loop 35 until {1 + 2 } do integer end loop } failed 9.3 Priority and assoziativity When a syntax construct has parameters before the first symbol or after the last symbol the priority and the associativity of the construct are significant. Constructs with stronger priority bind their parameters earlier than constructs with weaker priority. The priority is described by a natural number (inclusive 0). The strongest priority is 0. Weaker priorities are described by larger numbers. What bind means is can be declared with an example: = A + B = C * D / \ / \ * priority 6 + * + priority 7 / \ / \ = priority 12 A B C D First the * takes its parameters, then the + and at last the = follows. The associativity describes, in which order constructs with equal priority bind their parameters. For example A - B - C can be interpreted in two ways: (A - B) - C or A - (B - C) There are four associativities possible: Symbol Binding from left to right -> Binding from right to left <- Neither the left nor the right parameter are allowed to have the same priority <-> At the left side there is a binding from left to right and at the right side there is a binding from right to left -><- The last two possibilities give no legal interpretation in the subtraction example. The third kind of assiciativity ( <-> ) is used by the equal operator ( = ) of Pascal because there a expression like A = B = C is not legal. There is a second way to describe the associativity. The associativity describes if an operand must have a stronger priority than the priority of the operator. For example: - 7 A - B - C / \ / \ / \ <=7 / \ <7 - priority 7 -> / \ / \ - C 7 0 / \ / \ / \ <=7 / \ <7 / \ / \ A B 0 0 The numbers in the nodes of the right tree show the priority of each sub expression (sub tree). With < and <= the required condition for the priority of an operand is described. An interpretation is legal if all this conditions are met. If there are more than one legal interpretations or no legal interpretation the expression is illegal. Table for the possibilities of associativity: +---------------+------------------------------+ | associativity | The priority of the | +---------------+--------------+---------------+ | | left operand | right operand | | | must be | must be | +---------------+--------------+---------------+ | -> | <= | < | | <- | < | <= | | <-> | < | < | | -><- | <= | <= | +---------------+--------------+---------------+ | | than that of the operator | +---------------+------------------------------+ The parameter before the operator symbol is called left operand. The parameter after the last symbol of a construct is called right operand. In case of normal operators the last symbol of a construct and the operator symbol are identical. If this is not the case there is a third kind of operand. Between the operator symbol and the last symbol of a construct are the middle operands. Middle operands can have any priority. 9.4 The syntax of operators The S7SSD treats everything as operator description. Operators have priority and assoziativity. The priority and associativity determine in which succession the S7SSD syntax rules get applied. To explain priority and assoziativity we use the basic arithmetic operations (+,-,*,/). To describe them with EBNF you can write: factor := number | name . expression_5 ::= factor | ( '+' expression_5 ) | ( '-' expression_5 ) . expression_6 ::= expression_5 | ( expression_6 '*' expression_7 ) | ( expression_6 '/' expression_7 ) . expression_7 ::= expression_6 | ( expression_7 '+' expression_6 ) | ( expression_7 '-' expression_6 ) . This describes the following things: - The operators have different priorities: - Plus and minus signs are executed first - Multiplication and division are executed second. - Addition and subtraction are executed last. - This priorities are exactly what you expect from an arithmetic expression. - Additionally you see that ++2 is allowed and interpreted as +(+(2)) which means that the plus sign is a right-associative operator. - You can also see that a*b*c is allowed and interpreted as (a*b)*c which means that the multiplication is a left-associative operator. All this things can also be described with S7SSD: $ syntax expr: . + .() is <- 5; $ syntax expr: . - .() is <- 5; $ syntax expr: .(). * .() is -> 6; $ syntax expr: .(). / .() is -> 6; $ syntax expr: .(). + .() is -> 7; $ syntax expr: .(). - .() is -> 7; As you can see the S7SSD is shorter as the description with EBNF. A syntax statement is expained as follows: - The $ is used to introduce all hardcoded statements. - The keyword 'syntax' introduces a structured syntax description. - The result of the recognized expression will have the type 'expr'. The type 'expr' is used between the syntax and the semantic analysis. The type 'expr' describes expressions which are syntactically analyzed but not semantically analyzed. After the semantic analysis (and during the runtime) the type 'expr' is not used. - The colon ':' is used as separator between type and syntax description. - A dot expression like '.(). * .()' is introduced (as can probably be guessed by the name) with a dot. For the purpose of the syntax description you can just remove the dots in your mind: '() * ()' - The symbol 'is' is used in all Seed7 declarations as separator between the name and the value. - The associativity is described with one of the symbols -> (left-associative), <- (right-associative), <-> (not associative) and -><- (both associativitys). When there are no left or right operands, as it is the case for the 'loop' statement, the associativity is irrelevant. - Finally the priority of the syntax construct is defined with a integer literal like '6'. The priority '6' is used for the operators '*', '/', 'div', 'rem', 'mdiv' and 'mod'. The S7SSD can also be easily used to do automatic syntax recognition. There are also other things which are out of the scope of the S7SSD. The syntax of tokens (whitespace, comments, identifiers and literals) and expressions (parentheses, function calls and dot expressions) is hardcoded. The hardcoded constructs are described in chapter 10 (Tokens) and chapter 11 (Expressions). For the reasons mentioned above it is not possible to transform every EBNF syntax description into S7SSD. Transforming S7SSD descriptions to EBNF is always possible. The advantage of the S7SSD lies in its simplicity and that a fast automated syntax recognition algorithm can be easily implemented. It is exactly the combination of hardcoded syntax recognition and flexible syntax rules that make it successful. 9.5 Comparison of EBNF and S7SSD In the S7SSD of the 'loop' statement $ syntax expr: .loop.().until.().do.().end.loop is -> 25; are no nonterminal expressions '()' before the first keyword or after the last keyword. Therefore the assoziativity does not play any role. The nonterminal expressions '()' of the 'loop' statement are all surrounded by keywords and therefore they can have any priority. As priority of the 'loop' 25 is choosen just because most other statements have also priority 25. The assignments (:= +:= *:= ...) have priority 20 and all operators used in arithmetic, boolean and string expressions have priorities less than 20. BTW: The semicolon operator (;) is defined with the priority 50. Operators with a priority of 0 get their parameters before operators with priority 1 and so on. The corresponding EBNF description of the 'loop' statement would be: expression_25 ::= 'loop' expression_127 'until' expression_127 'do' expression_127 'end' 'loop' . You must keep in mind that alternative rules for expression_25 are also possible and that for every priority level a rule like expression_127 ::= expression_126 . is defined. Additionally the following rules are defined: expression_0 ::= token | parentheses_expression | call_expression | dot_expression . token ::= identifier | literal . parentheses_expression ::= '(' expression_127 ')' . call_expression ::= expression_127 [ '(' [ expression_127 { ',' expression_127 } ] ')' ] . dot_expression ::= [ '.' ] call_expression { '.' call_expression } . When you want to use some special syntax which should be only allowed at some place you do the following: - Define the special syntax with S7SSD in a way that does not contradict with the rest of the syntax definitions. - Use semantic definitions to make sure that this syntax construct can only be used at the place desired. The 'elsif' and 'else' parts of the 'if' statement use this technic. The syntax of the 'elsif' and 'else' statement parts is: $ syntax expr: .elsif.().then.() is <- 60; $ syntax expr: .elsif.().then.().() is <- 60; $ syntax expr: .else.() is <- 60; The types 'ELSIF_RESULT' and 'ELSIF_PROC' are just defined to be usable for the 'elsif' and 'else' parts. A special variant of the 'if' statement is defined with a parameter of type 'ELSIF_PROC': $ syntax expr: .if.().then.().().end.if is -> 25; const proc: if (in boolean param) then (in proc param) (in ELSIF_PROC param) end if is action "PRC_IF_ELSIF"; With 'action' the primitive actions are used (instead of a high level definition written in Seed7). Primitive actions are explained here: http://seed7.sourceforge.net/manual/actions.htm The semantic part of the 'else' and 'elsif' part are defined with: const ELSIF_PROC: elsif (in boolean param) then (in proc param) is action "PRC_IF"; const ELSIF_PROC: elsif (in boolean param) then (in proc param) (in ELSIF_PROC param) is action "PRC_IF_ELSIF"; const ELSIF_PROC: else (in void param) is ELSIF_EMPTY; Since no other functions of type 'ELSIF_PROC' are defined only legal 'if' statements can be written. An explanation of the 'if' statement is here http://seed7.sourceforge.net/manual/stats.htm#if-statement ================================ Thanks in advance for your effort. 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, portable, runs under linux/unix/windows. -- Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a |
From: Conrad S. <con...@ca...> - 2008-10-07 19:39:13
|
Hi Thomas The below implementation is interesting, I'll try it out. My method was to use hash table with integer keys and TreeNode structs as values. My TreeNode struct is then simply const type: TreeNode is new struct var integer: left is -1; var integer: right is -1; var integer: item is 0; end struct; Where a negative index means 'uninitialized'. Cheers, Conrad On Tue, 2008-10-07 at 21:22 +0200, Thomas Mertes wrote: > Conrad Steenberg <con...@gm...> wrote: > > Hi > > > > Learning seed7, so please be gentle :-) > > > > I'm trying to implement a struct containing elements that are pointers > > to (or references of) the same struct. > > > > Something like > > const type: tn is new struct > > var ptr struct tn: left is NIL; > > var ptr struct tn: right is NIL; > > var integer: item is 0; > > end struct; > > > > In C it would look like this: > > typedef struct tn { > > struct tn* left; > > struct tn* right; > > int item; > > } > > > > Is there a way to achieve this? FWIW this is for a binary tree with > > integer items. > > Currently the support for pointers in Seed7 is not very good. It is > possible to declare pointers to existing structs, but currently it > is not possible to declare a struct which contains a pointer to > itself. This has to do with the missing possibility to use forward > declarations for types. Sorry, but it will take some time to fix > this. Other possibilities to declare cyclic pointer references are > currently also impossible. > > Luckily the OO concept of Seed7 can help here: > Structs can contain elements with interface types and interface > types can refer to structs of the same type. > > The following example shows how to do this: > The interface type 'element' will be used as "pointer": > > const type: element is new interface; > > An implementation type for the empty element (emptyElement) > can be used as basic implementation type from which other > implementation types can inherit: > > const type: emptyElement is new struct > end struct; > > That the implementation type 'emptyElement' implements the > interface type 'element' is described with: > > type_implements_interface(emptyElement, element); > > Since every Seed7 expression has exactly one type, it is > necessary to define a special NIL value (used with element.NIL) > for the type 'element': > > const element: (attr element) . NIL is emptyElement.value; > > Now the struct with two "pointers" and an 'integer' can be > declared: > > const type: treeElement is sub emptyElement struct > var element: left is element.NIL; > var element: right is element.NIL; > var integer: item is 0; > end struct; > > Finally the type 'treeElement' is defined as implementation > of the type 'element': > > type_implements_interface(treeElement, element); > > To allow the direct access to the structure elements 'left', right' > and 'item' for objects of type 'element' the following declarations > are necessary: > > const func element: (ref element param).left is DYNAMIC; > const varfunc element: (inout element param).left is DYNAMIC; > const func element: (ref element param).right is DYNAMIC; > const varfunc element: (inout element param).right is DYNAMIC; > const func integer: (ref element param).item is DYNAMIC; > const varfunc integer: (inout element param).item is DYNAMIC; > > When all this was declared the following code is possible: > > const proc: addItem (inout element: anElem, in integer: item) is func > begin > if anElem = element.NIL then > anElem := xalloc(treeElement.value); > anElem.item := item; > elsif item < anElem.item then > addItem(anElem.left, item); > elsif item > anElem.item then > addItem(anElem.right, item); > end if; > end func; > > const proc: listItems (in element: anElem) is func > begin > if anElem <> element.NIL then > listItems(anElem.left); > write(" " <& anElem.item); > listItems(anElem.right); > end if; > end func; > > const func integer: sum (in element: anElem) is func > result > var integer: result is 0; > begin > if anElem <> element.NIL then > result := anElem.item + sum(anElem.left) + sum(anElem.right); > end if; > end func; > > New elements can be created with the function 'xalloc'. > This way interface and implementation types help to provide the > pointer functionality. > > IMHO pointers are not always the best solution. Abstract data types > like dynamic arrays, hash tables, struct types and set types can > be used to declare data structures. Like structured programming > introduced structured statements to avoid goto statements the > structured abstract data types can be used to avoid pointers. > > If you have more questions, just ask. > > 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, portable, runs under linux/unix/windows. > -- ----------------------------------------------------------------------------- Conrad D. Steenberg Ph.D. con...@ca... Scientific Software Engineer http://www.nupack.org Pierce Bio-Engineering Lab Mail Code 114-96 California Institute of Technology Pasadena, CA, 91125 |
From: Thomas M. <tho...@gm...> - 2008-10-07 19:22:48
|
Conrad Steenberg <con...@gm...> wrote: > Hi > > Learning seed7, so please be gentle :-) > > I'm trying to implement a struct containing elements that are pointers > to (or references of) the same struct. > > Something like > const type: tn is new struct > var ptr struct tn: left is NIL; > var ptr struct tn: right is NIL; > var integer: item is 0; > end struct; > > In C it would look like this: > typedef struct tn { > struct tn* left; > struct tn* right; > int item; > } > > Is there a way to achieve this? FWIW this is for a binary tree with > integer items. Currently the support for pointers in Seed7 is not very good. It is possible to declare pointers to existing structs, but currently it is not possible to declare a struct which contains a pointer to itself. This has to do with the missing possibility to use forward declarations for types. Sorry, but it will take some time to fix this. Other possibilities to declare cyclic pointer references are currently also impossible. Luckily the OO concept of Seed7 can help here: Structs can contain elements with interface types and interface types can refer to structs of the same type. The following example shows how to do this: The interface type 'element' will be used as "pointer": const type: element is new interface; An implementation type for the empty element (emptyElement) can be used as basic implementation type from which other implementation types can inherit: const type: emptyElement is new struct end struct; That the implementation type 'emptyElement' implements the interface type 'element' is described with: type_implements_interface(emptyElement, element); Since every Seed7 expression has exactly one type, it is necessary to define a special NIL value (used with element.NIL) for the type 'element': const element: (attr element) . NIL is emptyElement.value; Now the struct with two "pointers" and an 'integer' can be declared: const type: treeElement is sub emptyElement struct var element: left is element.NIL; var element: right is element.NIL; var integer: item is 0; end struct; Finally the type 'treeElement' is defined as implementation of the type 'element': type_implements_interface(treeElement, element); To allow the direct access to the structure elements 'left', right' and 'item' for objects of type 'element' the following declarations are necessary: const func element: (ref element param).left is DYNAMIC; const varfunc element: (inout element param).left is DYNAMIC; const func element: (ref element param).right is DYNAMIC; const varfunc element: (inout element param).right is DYNAMIC; const func integer: (ref element param).item is DYNAMIC; const varfunc integer: (inout element param).item is DYNAMIC; When all this was declared the following code is possible: const proc: addItem (inout element: anElem, in integer: item) is func begin if anElem = element.NIL then anElem := xalloc(treeElement.value); anElem.item := item; elsif item < anElem.item then addItem(anElem.left, item); elsif item > anElem.item then addItem(anElem.right, item); end if; end func; const proc: listItems (in element: anElem) is func begin if anElem <> element.NIL then listItems(anElem.left); write(" " <& anElem.item); listItems(anElem.right); end if; end func; const func integer: sum (in element: anElem) is func result var integer: result is 0; begin if anElem <> element.NIL then result := anElem.item + sum(anElem.left) + sum(anElem.right); end if; end func; New elements can be created with the function 'xalloc'. This way interface and implementation types help to provide the pointer functionality. IMHO pointers are not always the best solution. Abstract data types like dynamic arrays, hash tables, struct types and set types can be used to declare data structures. Like structured programming introduced structured statements to avoid goto statements the structured abstract data types can be used to avoid pointers. If you have more questions, just ask. 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, portable, runs under linux/unix/windows. -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx |
From: Thomas M. <tho...@gm...> - 2008-10-05 20:14:56
|
johannes <joh...@we...> wrote: > Hello Thomas, you worte,that you'd be interested in errors related to > the compile prcess of sub7. I'm not shure if this is one, though im new > to linux and not yet used to work with the terminal. I assume that sub7 means Seed7. > I'm using Ubuntu 8.04 Hardy Heron and a Seed7 File with the Name > seed7_05_20080921.tgz. About the compiler I'm not sure. As I sad before, > I'm new to this hole stuff. > > I read that using Linux and a shell, I'd have to use a socalled > makefile. What exactly is this and how do I manage to create on? > Couldn't find informations on that. The make utility is used to manage the compilation process. The make utility uses a file named 'makefile' which contains informations about what files need to be processed (by the compiler or other tools) and the dependencies between this files. The 'makefile' contains rules to generate files. There are some precoditions (other files) which need to be present before some commands get executed which should create the file described with this rule. A detailed explanation of the make utility is here: http://en.wikipedia.org/wiki/Make_(software) > Yours Sincerly > Johannes Herzog > > > Error Log from my Terminal: > > johannes@Johannes:~/seed7/src$ make depend > gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow > -Wpointer-arith -M runerr.c option.c primitiv.c actlib.c arrlib.c [snip] Usually the command 'make depend' should create the file 'version.h'. When I execute 'make depend' it starts with: tm@penguin:~/seed7_5/seed7/src$ make depend echo "#define ANSI_C" > version.h echo "#define USE_DIRENT" >> version.h echo "#define PATH_DELIMITER '/'" >> version.h echo "#define CATCH_SIGNALS" >> version.h echo "#define USE_MMAP" >> version.h echo "#undef INCL_NCURSES_TERM" >> version.h echo "#undef INCL_CURSES_BEFORE_TERM" >> version.h echo "#undef MKDIR_WITH_ONE_PARAMETER" >> version.h ... For me this looks like a previous attempt with 'make depend' was somehow stopped (e.g. with CTRL-C or by an error in the makefile) and the file 'version.h' was not completely generated. How does your file 'version.h' look like? > infile.c:694: Fehler: »SEED7_LIBRARY« nicht deklariert (erste Benutzung > in dieser Funktion) This is another indication that the 'version.h' file was not created correctly. A correct 'version.h' file should contain a #define for SEED7_LIBRARY. on my computer 'version.h' contains the line: #define SEED7_LIBRARY "/home/tm/seed7_5/lib" I suggest you to start from the beginning with the command: make clear This removes all files created by previous calls of 'make'. Afther that use make depend and finally make this should work. If the same error happens again or some other error shows up please send me the file 'version.h' and the log again (just to be sure). 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, portable, runs under linux/unix/windows. -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx |
From: johannes <joh...@we...> - 2008-10-04 23:08:16
|
Hello Thomas, you worte,that you'd be interested in errors related to the compile prcess of sub7. I'm not shure if this is one, though im new to linux and not yet used to work with the terminal. I'm using Ubuntu 8.04 Hardy Heron and a Seed7 File with the Name seed7_05_20080921.tgz. About the compiler I'm not sure. As I sad before, I'm new to this hole stuff. I read that using Linux and a shell, I'd have to use a socalled makefile. What exactly is this and how do I manage to create on? Couldn't find informations on that. Yours Sincerly Johannes Herzog Error Log from my Terminal: johannes@Johannes:~/seed7/src$ make depend gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -M runerr.c option.c primitiv.c actlib.c arrlib.c biglib.c blnlib.c bstlib.c chrlib.c cmdlib.c dcllib.c drwlib.c enulib.c fillib.c fltlib.c hshlib.c intlib.c itflib.c kbdlib.c lstlib.c prclib.c prglib.c reflib.c rfllib.c scrlib.c sctlib.c setlib.c soclib.c strlib.c timlib.c typlib.c ut8lib.c exec.c doany.c memory.c act_comp.c prg_comp.c analyze.c syntax.c token.c parser.c name.c type.c expr.c atom.c object.c scanner.c literal.c numlit.c findid.c error.c infile.c symbol.c info.c stat.c fatal.c match.c syvarutl.c traceutl.c actutl.c arrutl.c executl.c blockutl.c entutl.c identutl.c chclsutl.c sigutl.c > c_depend gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -M hi.c > depend johannes@Johannes:~/seed7/src$ make gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c hi.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o runerr.o runerr.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o option.o option.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o primitiv.o primitiv.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o actlib.o actlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o arrlib.o arrlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o biglib.o biglib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o blnlib.o blnlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o bstlib.o bstlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o chrlib.o chrlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o cmdlib.o cmdlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o dcllib.o dcllib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o drwlib.o drwlib.c drwlib.c: In Funktion »drw_arc«: drwlib.c:253: Warnung: Übergabe des Arguments 5 von »drwArc« als »float« statt »double« aufgrund des Prototyps drwlib.c:253: Warnung: Übergabe des Arguments 6 von »drwArc« als »float« statt »double« aufgrund des Prototyps drwlib.c: In Funktion »drw_farcchord«: drwlib.c:561: Warnung: Übergabe des Arguments 5 von »drwFArcChord« als »float« statt »double« aufgrund des Prototyps drwlib.c:561: Warnung: Übergabe des Arguments 6 von »drwFArcChord« als »float« statt »double« aufgrund des Prototyps drwlib.c: In Funktion »drw_farcpieslice«: drwlib.c:594: Warnung: Übergabe des Arguments 5 von »drwFArcPieSlice« als »float« statt »double« aufgrund des Prototyps drwlib.c:594: Warnung: Übergabe des Arguments 6 von »drwFArcPieSlice« als »float« statt »double« aufgrund des Prototyps drwlib.c: In Funktion »drw_parc«: drwlib.c:994: Warnung: Übergabe des Arguments 5 von »drwPArc« als »float« statt »double« aufgrund des Prototyps drwlib.c:994: Warnung: Übergabe des Arguments 6 von »drwPArc« als »float« statt »double« aufgrund des Prototyps drwlib.c: In Funktion »drw_pfarcchord«: drwlib.c:1060: Warnung: Übergabe des Arguments 5 von »drwPFArcChord« als »float« statt »double« aufgrund des Prototyps drwlib.c:1060: Warnung: Übergabe des Arguments 6 von »drwPFArcChord« als »float« statt »double« aufgrund des Prototyps drwlib.c: In Funktion »drw_pfarcpieslice«: drwlib.c:1096: Warnung: Übergabe des Arguments 5 von »drwPFArcPieSlice« als »float« statt »double« aufgrund des Prototyps drwlib.c:1096: Warnung: Übergabe des Arguments 6 von »drwPFArcPieSlice« als »float« statt »double« aufgrund des Prototyps gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o enulib.o enulib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o fillib.o fillib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o fltlib.o fltlib.c fltlib.c: In Funktion »flt_dgts«: fltlib.c:309: Warnung: Übergabe des Arguments 1 von »fltDgts« als »float« statt »double« aufgrund des Prototyps fltlib.c: In Funktion »flt_ipow«: fltlib.c:556: Warnung: Übergabe des Arguments 1 von »fltIPow« als »float« statt »double« aufgrund des Prototyps fltlib.c: In Funktion »flt_rand«: fltlib.c:803: Warnung: Übergabe des Arguments 1 von »fltRand« als »float« statt »double« aufgrund des Prototyps fltlib.c:803: Warnung: Übergabe des Arguments 2 von »fltRand« als »float« statt »double« aufgrund des Prototyps fltlib.c: In Funktion »flt_str«: fltlib.c:934: Warnung: Übergabe des Arguments 1 von »fltStr« als »float« statt »double« aufgrund des Prototyps gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o hshlib.o hshlib.c hshlib.c: In Funktion »hsh_lng«: hshlib.c:1331: Warnung: Übergabe des Arguments 1 von »bld_int_temp« als vorzeichenbehaftet aufgrund des Prototyps gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o intlib.o intlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o itflib.o itflib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o kbdlib.o kbdlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o lstlib.o lstlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o prclib.o prclib.c prclib.c: In Funktion »prc_repeat«: prclib.c:858: Warnung: »cond« könnte in dieser Funktion uninitialisiert verwendet werden gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o prglib.o prglib.c prglib.c: In Funktion »prg_error_count«: prglib.c:243: Warnung: Übergabe des Arguments 1 von »bld_int_temp« als vorzeichenbehaftet aufgrund des Prototyps prglib.c: In Funktion »prg_fil_parse«: prglib.c:309: Warnung: Zeigerziele in Zuweisung unterscheiden sich im Vorzeichenbesitz prglib.c: In Funktion »prg_syobject«: prglib.c:583: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »strlen« unterscheiden sich im Vorzeichenbesitz gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o reflib.o reflib.c reflib.c: In Funktion »ref_file«: reflib.c:520: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »cstri_to_stri« unterscheiden sich im Vorzeichenbesitz reflib.c: In Funktion »ref_scan«: reflib.c:997: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »strlen« unterscheiden sich im Vorzeichenbesitz gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o rfllib.o rfllib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o scrlib.o scrlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o sctlib.o sctlib.c sctlib.c: In Funktion »sct_elem«: sctlib.c:346: Warnung: »result« könnte in dieser Funktion uninitialisiert verwendet werden gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o setlib.o setlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o soclib.o soclib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o strlib.o strlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o timlib.o timlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o typlib.o typlib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o ut8lib.o ut8lib.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o exec.o exec.c exec.c: In Funktion »exec_lambda«: exec.c:551: Warnung: »backup_block_result« könnte in dieser Funktion uninitialisiert verwendet werden gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o doany.o doany.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o memory.o memory.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o act_comp.o act_comp.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o prg_comp.o prg_comp.c prg_comp.c: In Funktion »prgFilParse«: prg_comp.c:202: Warnung: Zeigerziele in Zuweisung unterscheiden sich im Vorzeichenbesitz prg_comp.c:208: Warnung: Zeigerziele in Zuweisung unterscheiden sich im Vorzeichenbesitz prg_comp.c: In Funktion »prgSyobject«: prg_comp.c:350: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »strlen« unterscheiden sich im Vorzeichenbesitz gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o analyze.o analyze.c analyze.c: In Funktion »analyze«: analyze.c:537: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »strlen« unterscheiden sich im Vorzeichenbesitz analyze.c:537: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »__builtin_strcmp« unterscheiden sich im Vorzeichenbesitz analyze.c:537: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »strlen« unterscheiden sich im Vorzeichenbesitz analyze.c:537: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »__builtin_strcmp« unterscheiden sich im Vorzeichenbesitz analyze.c:537: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »__builtin_strcmp« unterscheiden sich im Vorzeichenbesitz analyze.c:537: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »__builtin_strcmp« unterscheiden sich im Vorzeichenbesitz analyze.c: In Funktion »analyze_string«: analyze.c:603: Warnung: Zeigerziele bei Übergabe des Arguments 1 von »analyze_prog« unterscheiden sich im Vorzeichenbesitz gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o syntax.o syntax.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o token.o token.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o parser.o parser.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o name.o name.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o type.o type.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o expr.o expr.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o atom.o atom.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o object.o object.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o scanner.o scanner.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o literal.o literal.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o numlit.o numlit.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o findid.o findid.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o error.o error.c gcc -O2 -g -Wall -Wstrict-prototypes -Winline -Wconversion -Wshadow -Wpointer-arith -c -o infile.o infile.c infile.c: In Funktion »speedup«: infile.c:175: Warnung: Übergabe des Arguments 6 von »mmap« mit anderer Breite aufgrund des Prototyps infile.c:180: Warnung: Zeigerziele in Zuweisung unterscheiden sich im Vorzeichenbesitz infile.c: In Funktion »init_lib_path«: infile.c:694: Fehler: »SEED7_LIBRARY« nicht deklariert (erste Benutzung in dieser Funktion) infile.c:694: Fehler: (Jeder nicht deklarierte Bezeichner wird nur einmal aufgeführt infile.c:694: Fehler: für jede Funktion in der er auftritt.) make: *** [infile.o] Fehler 1 |
From: Conrad S. <con...@gm...> - 2008-09-29 03:40:57
|
Hi Learning seed7, so please be gentle :-) I'm trying to implement a struct containing elements that are pointers to (or references of) the same struct. Something like const type: tn is new struct var ptr struct tn: left is NIL; var ptr struct tn: right is NIL; var integer: item is 0; end struct; In C it would look like this: typedef struct tn { struct tn* left; struct tn* right; int item; } Is there a way to achieve this? FWIW this is for a binary tree with integer items. Thanks, Conrad -- ----------------------------------------------------------------------------- Conrad D. Steenberg Ph.D. con...@ca... Scientific Software Engineer http://www.nupack.org Pierce Bio-Engineering Lab Mail Code 114-96 California Institute of Technology Pasadena, CA, 91125 |
From: Conrad S. <con...@gm...> - 2008-09-28 22:08:51
|
Hi Thomas Thanks for your very detailed answer. I'll intersperse replies to your questions below: On Sun, 2008-09-28 at 22:20 +0200, Thomas Mertes wrote: > "Conrad Steenberg" <con...@ca...> wrote: > > Hi Thomas et al. :-) > > > > I've been playing with seed7 for a while and like the fact that it has > > both an interpreter to create portable or fast native code. > > > > My apologies if this is a FAQ: > > Is it possible to call C code in a different library from compiled s7 > > code? > > Currently there is no easy way to do this (call C code in a > different library). In the future an easier and simpler foreign > function interface will be introduced. > > Because Seed7 programs and the Seed7 interpreter and compiler should > achieve maximum portability the calling of foreign functions is > not a priority. But I see also the advantages of an foreign function > interface. That is a very good goal, yes. FWIW Python ctypes can probably be adapted for this purpose - it uses libffi to provide cross-platform portability (see http://sourceware.org/libffi/ and http://en.wikipedia.org/wiki/Libffi). > What functions from which library you want to call? My specific interest is in numerical analysis, so I'm thinking of things like LAPACK and BLAS, both of which are very portable. I also tinker around with "service-based" RPCs where having code mobility to different platforms, along with strict type checking are great assets. > Maybe it is possible to write a portable interface to this library. Yes, that would be the way to do it. I'm thinking of the way that Numerical Python works. > > The current way to call functions from external libraries is as > follows: > Functions of external libraries are introduced as primitive actions > to the hi interpreter. The primitive actions are described here: > http://seed7.sourceforge.net/manual/actions.htm > > The primitive action which describes the addition of two integers > is INT_ADD. The Seed7 interface to the INT_ADD action is defined > in the file seed7_05.s7i with: > > const func integer: (in integer param) + (in integer param) is action "INT_ADD"; > > To use a primitive action it is necessary to define it in the hi > interpreter. In the hi interpreter every primitive action is > described with a function which describes it. The function for the > INT_ADD action is int_add(). The int_add() function is defined in > the file intlib.c with; > > #ifdef ANSI_C > > objecttype int_add (listtype arguments) > #else > > objecttype int_add (arguments) > listtype arguments; > #endif > > { /* int_add */ > isit_int(arg_1(arguments)); > isit_int(arg_3(arguments)); > return(bld_int_temp( > take_int(arg_1(arguments)) + > take_int(arg_3(arguments)))); > } /* int_add */ > > Note that ansi C prototypes and K&R function headers are used. The > int_add() function adds the first and the third argument (the second > argument contains the + symbol. Several macros and helper functions > are used in this functions. > > - The macros 'arg_1', 'arg_2', 'arg_3', etc. can be used to get an > individual argument (E.g.: 'arg_3(arguments)' ). > - The macros 'isit_int', 'isit_stri', 'isit_file', etc. can be > used to check for the correct category of an argument > (E.g.: 'isit_int(arg_1(arguments))' ). > - The macros 'take_char', 'take_float', 'take_bigint', etc. can be > used to get the corresponding value of an argument > (E.g.: 'take_int(arg_1(arguments))' ). > - The functions 'bld_int_temp', 'bld_array_temp', 'bld_win_temp', > etc. can be used to create the (objecttype) result of a primitiv > action (E.g.: 'return(bld_int_temp(0))' ). > > The file intlib.h contains the prototype for the int_add function: > > objecttype int_add (listtype); > > and also a definition for the K&R C language: > > objecttype int_add (); > > Additionally every primitive action is registered in the file > primitive.c, The line which registrates INT_ADD is: > > { "INT_ADD", int_add, }, > > Note that all primitive action entries in the file primitive.c are > sorted alphabetically. With this definitions the hi interpreter > understands a primitive action. OK, this makes perfect sense. > > To allow an primitive function in a compiled Seed7 program the Seed7 > compiler (comp.sd7) needs to know the action also. The compiler > function which creates code for the INT_ADD action is: > > const proc: process_int_add (in ref_list: params, inout expr_type: c_expr) is func > > begin > c_expr.expr &:= "("; > process_expr(params[1], c_expr); > c_expr.expr &:= ") + ("; > process_expr(params[3], c_expr); > c_expr.expr &:= ")"; > end func; > > This function is called from the function process_action with the > line: > > elsif action_name = "INT_ADD" then > process_int_add(params, c_expr); > > Some primitive actions are more complicated and inline code would > not be the best solution for it. In this case an additional helper > function is used. The INT_STR function is such a function. The > definition of the int_str function in the file intlib.c is: > > #ifdef ANSI_C > > objecttype int_str (listtype arguments) > #else > > objecttype int_str (arguments) > listtype arguments; > #endif > > { /* int_str */ > isit_int(arg_1(arguments)); > return(bld_stri_temp(intStr( > take_int(arg_1(arguments))))); > } /* int_str */ > > The main work for the INT_STR primitive action is done in the helper > function intStr(). The helper function intStr() can be found in the > file int_rtl.c; > > #ifdef ANSI_C > > stritype intStr (inttype number) > #else > > stritype intStr (number) > inttype number; > #endif > > { > uinttype unsigned_number; > booltype sign; > strelemtype buffer_1[50]; > strelemtype *buffer; > memsizetype len; > stritype result; > > /* intStr */ > if ((sign = (number < 0))) { > unsigned_number = -number; > } else { > unsigned_number = number; > } /* if */ > buffer = &buffer_1[50]; > do { > *(--buffer) = (strelemtype) (unsigned_number % 10 + '0'); > } while ((unsigned_number /= 10) != 0); > if (sign) { > *(--buffer) = (strelemtype) '-'; > } /* if */ > len = &buffer_1[50] - buffer; > if (!ALLOC_STRI(result, len)) { > raise_error(MEMORY_ERROR); > return(NULL); > } else { > result->size = len; > memcpy(result->mem, buffer, (SIZE_TYPE) (len * sizeof(strelemtype))); > return(result); > } /* if */ > } /* intStr */ > > The file int_rtl.h contains a prototype definition for the intStr() > helper function: > > stritype intStr (inttype number); > > and also a definition for the K&R C language: > > stritype intStr (); > > The helper functions are also used in the code generated by the > Seed7 compiler: > > const proc: process_int_str (in ref_list: params, inout expr_type: c_expr) is func > > begin > prepare_stri_result(c_expr); > c_expr.result_expr &:= "intStr("; > getStdParamToResultExpr(params[1], c_expr); > c_expr.result_expr &:= ")"; > end func; > > As I said I normaly prefer a portable solution to provide > functionality. This means that the helper functions should be > written in a portable manner and use only portable libraries. > If this is not possible the helper functions should be written > as drivers. To support graphics under linux (with X11) and > windows (with gdi) there are two driver libraries: > drw_x11.c and drw_win.c . Such driver libraries should provide > the same functionality under different operating systems. > The headers for the drawing helper functions is defined in the > file drw_drv.h . The drawing actions are defined in the file > drwlib.c . > > I hope that this explanation helps. > If you need more information, just tell. Thanks, that helps a lot! Since I'm still learning the language I'll implement a few algorithms and see how it goes. Regards, Conrad > > 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, portable, runs under linux/unix/windows. > -- ----------------------------------------------------------------------------- Conrad D. Steenberg Ph.D. con...@ca... Scientific Software Engineer http://www.nupack.org Pierce Bio-Engineering Lab Mail Code 114-96 California Institute of Technology Pasadena, CA, 91125 |
From: Thomas M. <tho...@gm...> - 2008-09-28 20:20:42
|
"Conrad Steenberg" <con...@ca...> wrote: > Hi Thomas et al. :-) > > I've been playing with seed7 for a while and like the fact that it has > both an interpreter to create portable or fast native code. > > My apologies if this is a FAQ: > Is it possible to call C code in a different library from compiled s7 > code? Currently there is no easy way to do this (call C code in a different library). In the future an easier and simpler foreign function interface will be introduced. Because Seed7 programs and the Seed7 interpreter and compiler should achieve maximum portability the calling of foreign functions is not a priority. But I see also the advantages of an foreign function interface. What functions from which library you want to call? Maybe it is possible to write a portable interface to this library. The current way to call functions from external libraries is as follows: Functions of external libraries are introduced as primitive actions to the hi interpreter. The primitive actions are described here: http://seed7.sourceforge.net/manual/actions.htm The primitive action which describes the addition of two integers is INT_ADD. The Seed7 interface to the INT_ADD action is defined in the file seed7_05.s7i with: const func integer: (in integer param) + (in integer param) is action "INT_ADD"; To use a primitive action it is necessary to define it in the hi interpreter. In the hi interpreter every primitive action is described with a function which describes it. The function for the INT_ADD action is int_add(). The int_add() function is defined in the file intlib.c with; #ifdef ANSI_C objecttype int_add (listtype arguments) #else objecttype int_add (arguments) listtype arguments; #endif { /* int_add */ isit_int(arg_1(arguments)); isit_int(arg_3(arguments)); return(bld_int_temp( take_int(arg_1(arguments)) + take_int(arg_3(arguments)))); } /* int_add */ Note that ansi C prototypes and K&R function headers are used. The int_add() function adds the first and the third argument (the second argument contains the + symbol. Several macros and helper functions are used in this functions. - The macros 'arg_1', 'arg_2', 'arg_3', etc. can be used to get an individual argument (E.g.: 'arg_3(arguments)' ). - The macros 'isit_int', 'isit_stri', 'isit_file', etc. can be used to check for the correct category of an argument (E.g.: 'isit_int(arg_1(arguments))' ). - The macros 'take_char', 'take_float', 'take_bigint', etc. can be used to get the corresponding value of an argument (E.g.: 'take_int(arg_1(arguments))' ). - The functions 'bld_int_temp', 'bld_array_temp', 'bld_win_temp', etc. can be used to create the (objecttype) result of a primitiv action (E.g.: 'return(bld_int_temp(0))' ). The file intlib.h contains the prototype for the int_add function: objecttype int_add (listtype); and also a definition for the K&R C language: objecttype int_add (); Additionally every primitive action is registered in the file primitive.c, The line which registrates INT_ADD is: { "INT_ADD", int_add, }, Note that all primitive action entries in the file primitive.c are sorted alphabetically. With this definitions the hi interpreter understands a primitive action. To allow an primitive function in a compiled Seed7 program the Seed7 compiler (comp.sd7) needs to know the action also. The compiler function which creates code for the INT_ADD action is: const proc: process_int_add (in ref_list: params, inout expr_type: c_expr) is func begin c_expr.expr &:= "("; process_expr(params[1], c_expr); c_expr.expr &:= ") + ("; process_expr(params[3], c_expr); c_expr.expr &:= ")"; end func; This function is called from the function process_action with the line: elsif action_name = "INT_ADD" then process_int_add(params, c_expr); Some primitive actions are more complicated and inline code would not be the best solution for it. In this case an additional helper function is used. The INT_STR function is such a function. The definition of the int_str function in the file intlib.c is: #ifdef ANSI_C objecttype int_str (listtype arguments) #else objecttype int_str (arguments) listtype arguments; #endif { /* int_str */ isit_int(arg_1(arguments)); return(bld_stri_temp(intStr( take_int(arg_1(arguments))))); } /* int_str */ The main work for the INT_STR primitive action is done in the helper function intStr(). The helper function intStr() can be found in the file int_rtl.c; #ifdef ANSI_C stritype intStr (inttype number) #else stritype intStr (number) inttype number; #endif { uinttype unsigned_number; booltype sign; strelemtype buffer_1[50]; strelemtype *buffer; memsizetype len; stritype result; /* intStr */ if ((sign = (number < 0))) { unsigned_number = -number; } else { unsigned_number = number; } /* if */ buffer = &buffer_1[50]; do { *(--buffer) = (strelemtype) (unsigned_number % 10 + '0'); } while ((unsigned_number /= 10) != 0); if (sign) { *(--buffer) = (strelemtype) '-'; } /* if */ len = &buffer_1[50] - buffer; if (!ALLOC_STRI(result, len)) { raise_error(MEMORY_ERROR); return(NULL); } else { result->size = len; memcpy(result->mem, buffer, (SIZE_TYPE) (len * sizeof(strelemtype))); return(result); } /* if */ } /* intStr */ The file int_rtl.h contains a prototype definition for the intStr() helper function: stritype intStr (inttype number); and also a definition for the K&R C language: stritype intStr (); The helper functions are also used in the code generated by the Seed7 compiler: const proc: process_int_str (in ref_list: params, inout expr_type: c_expr) is func begin prepare_stri_result(c_expr); c_expr.result_expr &:= "intStr("; getStdParamToResultExpr(params[1], c_expr); c_expr.result_expr &:= ")"; end func; As I said I normaly prefer a portable solution to provide functionality. This means that the helper functions should be written in a portable manner and use only portable libraries. If this is not possible the helper functions should be written as drivers. To support graphics under linux (with X11) and windows (with gdi) there are two driver libraries: drw_x11.c and drw_win.c . Such driver libraries should provide the same functionality under different operating systems. The headers for the drawing helper functions is defined in the file drw_drv.h . The drawing actions are defined in the file drwlib.c . I hope that this explanation helps. If you need more information, just tell. 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, portable, runs under linux/unix/windows. -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx |
From: Conrad S. <con...@ca...> - 2008-09-24 05:45:17
|
Hi Thomas et al. :-) I've been playing with seed7 for a while and like the fact that it has both an interpreter to create portable or fast native code. My apologies if this is a FAQ: Is it possible to call C code in a different library from compiled s7 code? Thanks! Conrad -- ----------------------------------------------------------------------------- Conrad D. Steenberg Ph.D. con...@ca... Scientific Software Engineer http://www.nupack.org Pierce Bio-Engineering Lab Mail Code 114-96 California Institute of Technology Pasadena, CA, 91125 |
From: Thomas M. <tho...@gm...> - 2008-07-15 09:47:51
|
Frank Swarbrick <fsw...@gm...> wrote: > Hi. I thought you might be interested that I have been successful in > building seed7 with Mac OS X 10.5.4. Great. Thank you for the feedback. I hope you enjoy Seed7. If you have questions or suggestions, just ask. > The only special requirements appear to me that the Developer Tools must > be installed (fairly obvious!) and the LIBRARY_PATH environment variable > must include /usr/X11R6/lib in order to pick up the X11 library modules. Recently I was in a shop, where they had an Apple exhibition. All machines there had no Developer Tools, so I was not able to compile anything. The sales people, not even the one from Apple, were not able to tell me how to install the Developer tools. Additionally the person from Apple did not even know whom to ask for a solution. It was a sad experience. Could you provide me with a detailed description to install the Developer Tools. I would like to add a detailed description of how to compile under Mac OS X to the read_me. > Just thought I'd mention it in case anyone is interested. > > I did get a lot of warnings during make, but no show stoppers that I can > see. I've attached the output. This warnings are issued also under Linux. BTW. I assume you used the 'makefile', not one of the 'mk_*.mak' files. Do you think, a 'mk_mac.mak' makefile which takes care for the X11 path, would make sense? 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, portable, runs under linux/unix/windows. -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer |
From: Thomas M. <tho...@gm...> - 2008-07-08 10:55:36
|
I am so sorry that the message from "Hunt Delmonaco" with the subject "[Seed7-users] enclasp unsocialized" escaped my manual spam check. PLEASE DO NOT OPEN THE ATTACHMENTS OF THE "enclasp unsocialized" MESSAGE FROM "Hunt Delmonaco" AS I CANNOT GUARANTEE THAT THEY DON'T CONTAIN A VIRUS. I have added the email address of "Hunt Delmonaco" to the reject list. So this will hopefully not happen aggain. Please accept my apology. I will try my very best, that such things not happen aggain. 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, portable, runs under linux/unix/windows. -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx |
From: Hunt D. <so...@or...> - 2008-07-05 10:51:27
|
Hallo, http://www.capedyinlax[JD]com Have risen and followed, but the queen and lord yet thankful to her for making a jest to others they were all horrible to me. If i could only but that the integrity of the shah's empire may subject for the gentleman whoerresided with dr. mutilating himself. He had got to plunge into even cards, to amuse a fellow. And when my mother his daughter maiwa, and squatted on their haunches ties are very strong, and are carried down even why vida had married raymie (which included some in an oven, with some fried sausages made of minced you know, said jane. Yes, it is jane's fault entirely,. |