Author Topic: TinyScheme  (Read 63631 times)

0 Members and 1 Guest are viewing this topic.

RobbeK

  • Guest
Re: TinyScheme
« Reply #180 on: September 09, 2014, 02:43:48 PM »
Hi John ...   TinyScheme has the full power of writing any macro-expansion whatsoever !! 8)

JRS

  • Guest
Re: TinyScheme
« Reply #181 on: September 09, 2014, 02:51:28 PM »
I'm still waiting for you to fall in love with SB / TS / SDL_gfx. I would be willing to add SDL_gfx to TS if you were to show some interest in this direction. Time is running out and I'm getting close to wrapping up the SB/TS project. I need to move on to COM/VB and getting the SB 2.2 release finalized.


JRS

  • Guest
Re: TinyScheme
« Reply #182 on: September 09, 2014, 07:56:06 PM »
Quote from: Mike
I think this will fix your console output for long numbers.

I made your changes on a fresh copy of the source and we are still getting zeros from fields 33 to 64.


Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #183 on: September 09, 2014, 08:44:44 PM »
I made your changes on a fresh copy of the source and we are still getting zeros from fields 33 to 64.

Would you be so kind as to do me a favour by spending three minutes of your precious time on the following:


1. Take the three source files of Tiny Scheme that I've recently fixed for use under 64 bits and uploaded here.

2. Overwrite what's there in my fixed scheme.c with my latest fixes taken from this message of mine.

3. Compile the three files with your TDM GCC under your 64-bit Windows 7.


I'm dying to be shown what the resultant exe will print in response to King's Reward.

Thanks!

JRS

  • Guest
Re: TinyScheme
« Reply #184 on: September 09, 2014, 08:54:30 PM »

C:\tinyscheme-master\src>mingw32-make -B
gcc -fpic -pedantic -I. -c -g -Wno-char-subscripts -O -DUSE_STRLWR=0 -DUSE_DL=1 -DUSE_MATH=1 -DUSE_ASCII_NAMES=0  scheme.c
scheme.c: In function 'alloc_cellseg':
scheme.c:584:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
          if(((unsigned long)cp)%adj!=0) {
              ^
scheme.c:585:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
            cp=(char*)(adj*((unsigned long)cp/adj+1));
                            ^
scheme.c:585:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
            cp=(char*)(adj*((unsigned long)cp/adj+1));
               ^
scheme.c: In function 'mk_atom':
scheme.c:1143:41: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
    return mk_real(sc, strtold(q, NULL));//    atof(q));
                                         ^
scheme.c:1143:41: warning: (this will be reported only once per input file) [enabled by default]
scheme.c: In function 'opexe_2':
scheme.c:3176:11: warning: passing argument 2 of 'modf' from incompatible pointer type [enabled by default]
           } else if(modf(rvalue_unchecked(x),&dd)==0.0) {
           ^
In file included from scheme.c:29:0:
c:\tdm-gcc-64\x86_64-w64-mingw32\include\math.h:196:18: note: expected 'double *' but argument is of type 'long double *'
   double __cdecl modf(double _X,double *_Y);
                  ^
gcc -fpic -pedantic -I. -c -g -Wno-char-subscripts -O -DUSE_STRLWR=0 -DUSE_DL=1 -DUSE_MATH=1 -DUSE_ASCII_NAMES=0  dynload.c
dynload.c: In function 'scm_load_ext':
dynload.c:108:33: warning: ISO C forbids assignment between function pointer and 'void *' [-Wpedantic]
          *(void **)&module_init = dl_proc(dll_handle, init_fn);
                                 ^
gcc -shared -o libtinyscheme.dll scheme.o dynload.o -lm
ar crs libtinyscheme.a scheme.o dynload.o
gcc -fpic -pedantic -o scheme -g -Wno-char-subscripts -O scheme.o dynload.o -lm

C:\tinyscheme-master\src>dir


Output


C:\tinyscheme-master\src>scheme king.scm
The reward of the King
----------------------

 field 1  number of grains   1
 field 2  number of grains   2
 field 3  number of grains   4
 field 4  number of grains   8
 field 5  number of grains   16
 field 6  number of grains   32
 field 7  number of grains   64
 field 8  number of grains   128
 field 9  number of grains   256
 field 10  number of grains   512
 field 11  number of grains   1024
 field 12  number of grains   2048
 field 13  number of grains   4096
 field 14  number of grains   8192
 field 15  number of grains   16384
 field 16  number of grains   32768
 field 17  number of grains   65536
 field 18  number of grains   131072
 field 19  number of grains   262144
 field 20  number of grains   524288
 field 21  number of grains   1048576
 field 22  number of grains   2097152
 field 23  number of grains   4194304
 field 24  number of grains   8388608
 field 25  number of grains   16777216
 field 26  number of grains   33554432
 field 27  number of grains   67108864
 field 28  number of grains   134217728
 field 29  number of grains   268435456
 field 30  number of grains   536870912
 field 31  number of grains   1073741824
 field 32  number of grains   2147483648
 field 33  number of grains   4294967296
 field 34  number of grains   8589934592
 field 35  number of grains   17179869184
 field 36  number of grains   34359738368
 field 37  number of grains   68719476736
 field 38  number of grains   137438953472
 field 39  number of grains   274877906944
 field 40  number of grains   549755813888
 field 41  number of grains   1099511627776
 field 42  number of grains   2199023255552
 field 43  number of grains   4398046511104
 field 44  number of grains   8796093022208
 field 45  number of grains   17592186044416
 field 46  number of grains   35184372088832
 field 47  number of grains   70368744177664
 field 48  number of grains   140737488355328
 field 49  number of grains   281474976710656
 field 50  number of grains   562949953421312
 field 51  number of grains   1125899906842624
 field 52  number of grains   2251799813685248
 field 53  number of grains   4503599627370496
 field 54  number of grains   9007199254740992
 field 55  number of grains   18014398509481984
 field 56  number of grains   36028797018963968
 field 57  number of grains   72057594037927936
 field 58  number of grains   144115188075855872
 field 59  number of grains   288230376151711744
 field 60  number of grains   576460752303423488
 field 61  number of grains   1152921504606846976
 field 62  number of grains   2305843009213693952
 field 63  number of grains   4611686018427387904
 field 64  number of grains   -9223372036854775808

C:\tinyscheme-master\src>

« Last Edit: September 09, 2014, 09:08:10 PM by John »

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #185 on: September 09, 2014, 11:02:32 PM »
John,

Thank you very much for this listing. It shows that GCC cannot cope fully automatically with bitness conversion of the original code. I will install TDM GCC 4.8.1 under my 64-bit Windows 7, and I will take these sources as the basis for making a clean compilation of TS, and I will make all the intermediate test builds myself. So no more PITA for you with your extension module to your ScriptBASIC.

But be forewarned that 4.8.1 links against a thread handler that ships in a separate dll -- libgcc_s_dw2-1.dll. You will have to either ship this dll along with your TS distro (both 32 and 64 bits) or recompile my final sources with some earlier version of 64-bit TDM GCC that went without that multithreaded appendage.

JRS

  • Guest
Re: TinyScheme
« Reply #186 on: September 09, 2014, 11:08:37 PM »
Thanks Mike for all your efforts!

I think TS is becoming our Hello World for 32 to 64 bit migrations.  :)

JRS

  • Guest
Re: TinyScheme
« Reply #187 on: September 10, 2014, 07:23:58 AM »
Quote
So no more PITA for you with your extension module to your ScriptBASIC.

Is this still the plan or did I lose you to FBSL DynLisp?


Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #188 on: September 10, 2014, 08:48:14 AM »
Why, sure it is! How can I leave you in the middle of the road? DynLisp was mentioned in another thread... :)

JRS

  • Guest
Re: TinyScheme
« Reply #189 on: September 10, 2014, 09:09:43 AM »
Just making sure I didn't lose my Lisping buddy.  ;D

RobbeK

  • Guest
Re: TinyScheme
« Reply #190 on: September 10, 2014, 10:54:38 AM »
Hi John,

"Is it just me or does Lisp seem more popular and feature rich on the Linux side? "

Yes, I think the reason is that Unix is a lot older than Windows , from the early 70s and in the 80s already starting with the X Windows graphical environment, and of course Lisp is older than Unix -- so mainly for windows one has to translate existing Lisps. (which is still somewhat problematic for SBCL ).
I only know Corman Lisp being developed for the Win OS.  (http://www.cormanlisp.com/) , but it may be based on PowerLisp for the Mac.

From the MS side, there has been no interest at all concerning Lisp (they followed the popular line of the moment that every computer is equipped with a basic interpreter/(compiler) ) -- while the classical editor on the Unix systems, EMACS is written in Lisp and interactive with Lisp, and on their turn the intrest in BASIC form the *nix side is also very low...

btw Lisp already did a kind of JIT in 1960's  (fed with IBM punch cards)

it's something as

(define progA (read-punch-cards sourceA))
(define progB (read-punch-cards sourceB))
.
.
(define ActionA (lambda () (eval progA)))  ;;; this does the trick  other languages couldn't do in those days , they just read/ran the code of  the cards in sequence.

best, Rob

 
« Last Edit: September 10, 2014, 12:07:07 PM by RobbeK »

JRS

  • Guest
Re: TinyScheme
« Reply #191 on: September 10, 2014, 11:22:31 AM »
It only seems logical that BASIC with a Lisp extension is a way to bridge the gap.

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #192 on: September 10, 2014, 12:37:46 PM »
John,

As promised, attached please find the 64-bit TDM GCC 4.8.1 stuff. It comes in the /src directory in two flavors -- as a Code::Blocks workspace, for civilized devs, and a simple build_tdm_gcc_481_64.bat file, for geeks. Each one compiles TS faultlessly into a -O3 64-bit executable.

Make sure to cd into /src and run the batch file as Administrator.

On a side note:
-- this -O3 app runs much much faster than the 32-bit build; it does the doubly recursive fibo(35) in 20 secs only against the former 1:30 mins;
-- the latest TDM GCC 4.8.1 recognizes alien %l and %ll formats, reports them as errors, and aborts compilation. It took linuxoids no more than 10 years to become aware of this tiny difference between our platforms. It will take them yet another 10 (20 all in all) to realize that their bloody empty .bss sections in their crooked gcc executables are breaking the integrity of PE headers sticking far beyond their declared section boundaries. ;)

.

JRS

  • Guest
Re: TinyScheme
« Reply #193 on: September 10, 2014, 12:52:32 PM »
You're the man!

Code: [Select]
gcc.exe -Wall -O3 -Wno-unused -fno-strict-aliasing -fno-common  -c dynload.c -o ./obj/dynload.o
gcc.exe -Wall -O3 -Wno-unused -fno-strict-aliasing -fno-common  -c scheme.c -o ./obj/scheme.o
g++.exe  -o tinyscheme.exe ./obj/dynload.o ./obj/scheme.o -s


C:\TS_GCC_64\src>build_tdm_gcc_481_64.bat

C:\TS_GCC_64\src>gcc.exe -Wall -O3 -Wno-unused -fno-strict-aliasing -fno-common  -c dynload.c -o ./obj/dynload.o

C:\TS_GCC_64\src>gcc.exe -Wall -O3 -Wno-unused -fno-strict-aliasing -fno-common  -c scheme.c -o ./obj/scheme.o

C:\TS_GCC_64\src>g++.exe  -o tinyscheme.exe ./obj/dynload.o ./obj/scheme.o -s

C:\TS_GCC_64\src>


Output


C:\TS_GCC_64\src>tinyscheme king.scm
The reward of the King
----------------------

 field 1  number of grains   1
 field 2  number of grains   2
 field 3  number of grains   4
 field 4  number of grains   8
 field 5  number of grains   16
 field 6  number of grains   32
 field 7  number of grains   64
 field 8  number of grains   128
 field 9  number of grains   256
 field 10  number of grains   512
 field 11  number of grains   1024
 field 12  number of grains   2048
 field 13  number of grains   4096
 field 14  number of grains   8192
 field 15  number of grains   16384
 field 16  number of grains   32768
 field 17  number of grains   65536
 field 18  number of grains   131072
 field 19  number of grains   262144
 field 20  number of grains   524288
 field 21  number of grains   1048576
 field 22  number of grains   2097152
 field 23  number of grains   4194304
 field 24  number of grains   8388608
 field 25  number of grains   16777216
 field 26  number of grains   33554432
 field 27  number of grains   67108864
 field 28  number of grains   134217728
 field 29  number of grains   268435456
 field 30  number of grains   536870912
 field 31  number of grains   1073741824
 field 32  number of grains   2147483648
 field 33  number of grains   4294967296
 field 34  number of grains   8589934592
 field 35  number of grains   17179869184
 field 36  number of grains   34359738368
 field 37  number of grains   68719476736
 field 38  number of grains   137438953472
 field 39  number of grains   274877906944
 field 40  number of grains   549755813888
 field 41  number of grains   1099511627776
 field 42  number of grains   2199023255552
 field 43  number of grains   4398046511104
 field 44  number of grains   8796093022208
 field 45  number of grains   17592186044416
 field 46  number of grains   35184372088832
 field 47  number of grains   70368744177664
 field 48  number of grains   140737488355328
 field 49  number of grains   281474976710656
 field 50  number of grains   562949953421312
 field 51  number of grains   1125899906842624
 field 52  number of grains   2251799813685248
 field 53  number of grains   4503599627370496
 field 54  number of grains   9007199254740992
 field 55  number of grains   18014398509481984
 field 56  number of grains   36028797018963968
 field 57  number of grains   72057594037927936
 field 58  number of grains   144115188075855872
 field 59  number of grains   288230376151711744
 field 60  number of grains   576460752303423488
 field 61  number of grains   1152921504606846976
 field 62  number of grains   2305843009213693952
 field 63  number of grains   4611686018427387904
 field 64  number of grains   -9223372036854775808


C:\TS_GCC_64\src>


Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #194 on: September 10, 2014, 01:05:52 PM »
Glad you like it. :)

It's a pity Rob doesn't run 64 bits. It would be nice to test TS' trigonometry and rounding functions to see if they work well from the point of view of Windows' pseudo long doubles.

Perhaps he can provide some simple test functions in the Scheme dialect to see if the results are consistent.