Author Topic: TinyScheme  (Read 63639 times)

0 Members and 2 Guests are viewing this topic.

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #150 on: September 07, 2014, 10:01:52 AM »
But you don't need either SB or Peter Verhas to build Tiny Scheme. 12 years is a lot of time in IT. I think the first LISPs were either machine coded or card punched by hand but it doesn't mean we're suppused to "maintain the tradition" building TS in the year of 2014.

As a matter of fact, your SB sources for Windows can also be formulated as a Code::Blocks MinGW  workspace or VS2013 solution to make editing and compilation more up to date and dev friendly. You're so concerned about BASIC's future and you're clutching so tightly onto the past with its development tools.

JRS

  • Guest
Re: TinyScheme
« Reply #151 on: September 07, 2014, 10:15:15 AM »
If you download Dave COM project, (IDE/Debugger) he uses the method you just mentioned to build SB within VS. He even did a YouTube video on how to set it up. As you know, Windows is a secondary platform for me and if it wasn't for you and Charles's help, I wouldn't be spending the time I have on this. Linux is just easier to use (for me) and ahead of the game in many areas. (IMHO) Being open source is icing.

JRS

  • Guest
Re: TinyScheme
« Reply #152 on: September 07, 2014, 05:36:49 PM »
Mike,

Just wanted to say what a great job you did on the TinyScheme Windows 32 bit to 64 bit conversion. This will help a lot with the TSX extension conversion.


long = __int64
int = __int64
double = long double


The following lines needed special attention and if you have time to explain these changes, it would also help in the understanding of this migration.


728 sc->fcells -= (long)n;
1888 p[0]=(char)c;
2043 *plen=(int)strlen(p);
3746 - 3754
          s_retbool(Cisalpha((int)ivalue(car(sc->args))));
     case OP_CHARNP:     /* char-numeric? */
       s_retbool(Cisdigit((int)ivalue(car(sc->args))));
     case OP_CHARWP:     /* char-whitespace? */
       s_retbool(Cisspace((int)ivalue(car(sc->args))));
     case OP_CHARUP:     /* char-upper-case? */
       s_retbool(Cisupper((int)ivalue(car(sc->args))));
     case OP_CHARLP:     /* char-lower-case? */
       s_retbool(Cislower((int)ivalue(car(sc->args))));
4018 size=(off_t)(p->rep.string.curr-p->rep.string.start+1);
5143 retcode=(int)sc.retcode;

« Last Edit: September 07, 2014, 07:00:00 PM by John »

JRS

  • Guest
Re: TinyScheme
« Reply #153 on: September 07, 2014, 10:45:45 PM »
Mike,

I'm working on the TSX extension module and have the following warnings. I did the int and long conversion but these warnings remain.  :(


C:\TS\tinyscheme-master\tsx>cl /nologo /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE /DWIN32 /DUSE_DL=1 /I..\src /MT tsx.c
tsx.c
tsx.c(328) : warning C4244: '=' : conversion from '__time64_t' to 'long', possible loss of data
tsx.c(410) : warning C4133: 'function' : incompatible types - from '__int64 *' to 'LPINT'
tsx.c(511) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
tsx.c(567) : warning C4244: 'function' : conversion from '__int64' to 'int', possible loss of data
tsx.c(625) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
tsx.c(682) : warning C4244: 'function' : conversion from '__int64' to 'int', possible loss of data

C:\TS\tinyscheme-master\tsx>link /nologo /DLL /out:dll\tsx.dll /export:init_tsx tsx.obj ws2_32.lib
   Creating library dll\tsx.lib and object dll\tsx.exp

C:\TS\tinyscheme-master\tsx>cl /nologo /O2 /W3 /c /D_CRT_SECURE_NO_DEPRECATE /DWIN32 /DUSE_DL=1 /I..\src /MDd tsx.c
tsx.c
tsx.c(328) : warning C4244: '=' : conversion from '__time64_t' to 'long', possible loss of data
tsx.c(410) : warning C4133: 'function' : incompatible types - from '__int64 *' to 'LPINT'
tsx.c(511) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
tsx.c(567) : warning C4244: 'function' : conversion from '__int64' to 'int', possible loss of data
tsx.c(625) : warning C4267: 'function' : conversion from 'size_t' to 'int', possible loss of data
tsx.c(682) : warning C4244: 'function' : conversion from '__int64' to 'int', possible loss of data

C:\TS\tinyscheme-master\tsx>link /nologo /DLL /out:dll\tsx_d.dll /export:init_tsx tsx.obj ws2_32.lib
   Creating library dll\tsx_d.lib and object dll\tsx_d.exp

C:\TS\tinyscheme-master\tsx>del tsx.obj

C:\TS\tinyscheme-master\tsx>

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #154 on: September 07, 2014, 11:42:45 PM »
John,

First and foremost, be prepared that conversion will be a multi-stage process. You won't be able to get rid of all warnings at once. As you fix the current list, new ones will spring up at various places because the declarations you've just fixed are referenced there. As you fix up those, they will cause yet more new warnings at different places and so on and so forth until the entire tree of cross references have gotten eventually fixed up.

This is a tiresome process and it is best dealt with in the Visual Studio IDE where you can click the compilation warnings list and use the RMB popup menu to jump to the corresponding structure and function declarations and definitions. Recompile after each session and be especially sure to clean the solution with the appropriate build menu item before each rebuild. Otherwise you may get your changes linked against the old object files that are still expecting int's and long's.

I can't offer more help right now after a night of heavy coding but I'll try and look into your questions more closely after some 7 or 8 hours of sleep.

Good night.

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #155 on: September 08, 2014, 07:21:20 AM »
Hi John,

Here are my explanations:


728 sc->fcells -= (long)n; // The number of memory cells (i.e. chunks) where TS stores its internal data
                                         // isn't platform-dependent. If the authors determined it to be, say, 5000 then
                                         // a
long-wide field is sufficient to store it on 64 bits too.

1888 p[0]=(char)c;          // p[] is a char array on any platform even if c is fetched
                                         // into the function in an
__int64-wide argument.

2043 *plen=(int)strlen(p); // That was an unwize decision. It should be a platform-dependent (size_t)
                                           // cast because 64-bit strings may be huge. Try changing the
*plen argument
                                           // to
__int64* plen or size_t* plen and fix up any extra compiler warnings
                                           // that may appear due to the change.


3746 - 3754                     // These are functions that return simple YES or NO (i.e. TRUE or FALSE) so there's
                                           // no need to make them any wider.

          s_retbool(Cisalpha((int)ivalue(car(sc->args))));
     case OP_CHARNP:     /* char-numeric? */
       s_retbool(Cisdigit((int)ivalue(car(sc->args))));
     case OP_CHARWP:     /* char-whitespace? */
       s_retbool(Cisspace((int)ivalue(car(sc->args))));
     case OP_CHARUP:     /* char-upper-case? */
       s_retbool(Cisupper((int)ivalue(car(sc->args))));
     case OP_CHARLP:     /* char-lower-case? */
       s_retbool(Cislower((int)ivalue(car(sc->args))));

4018 size=(off_t)(p->rep.string.curr-p->rep.string.start+1); // size is defined as off_t
                                                             // (i.e. offset_type) which is a platform-dependent
                                                             // quantity adjusted by the compiler to 64 bits
                                                             // automatically.


5143 retcode=(int)sc.retcode;// Retcodes are usually program-defined small values to signal TRUE or FALSE,
                                          // success or failure, etc. I don't think they will change all by themselves due to
                                          // migration to 64 bits.
« Last Edit: September 08, 2014, 08:46:06 AM by Mike Lobanovsky »

JRS

  • Guest
Re: TinyScheme
« Reply #156 on: September 08, 2014, 07:24:17 AM »
Thanks Mike for the explanation of the changes. Very helpful. Do have a moment to wrap up the warnings in the TSX extension module for TinyScheme 64?


Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #157 on: September 08, 2014, 07:30:56 AM »
First and foremost, be prepared that conversion will be a multi-stage process.

A moment, you say? ;)

JRS

  • Guest
Re: TinyScheme
« Reply #158 on: September 08, 2014, 07:52:00 AM »
Quote
A moment, you say?

I was in deep thought about what I'm going to have to do to fix SB Win 64 when I wrote that. Sorry.


Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #159 on: September 08, 2014, 08:35:47 AM »
I was in deep thought about what I'm going to have to do to fix SB Win 64...

Strictly speaking, I don't think you should make any fixes to your existing 64-bit SB under either Windows or Linux. If it compiles with GCC without complaints on both platforms just leave it as it is. If all its sizable types are properly defined with size_t, char_t, wchar_t, etc. automatic qualifiers then the compiler will do the job for you transparently. The only thing you will have to do manually is change your maths to 64 bits using long long versions of arguments and respective math functions like sinl(), fmodl(), etc. and string-to-number conversion functions like strtold(), etc.

Or you may leave the args and functions alone, in which case you will simply have the same old 32-bit maths and strings but on a 64-bit platform. The final decision is yours depending on expediency and your own willingness and perseverance.

JRS

  • Guest
Re: TinyScheme
« Reply #160 on: September 08, 2014, 09:48:18 AM »
Thanks Mike for having a peek under the covers at SB. Under Linux going to 64 bit was just a compiler switch. gcc sees long as a 64 bit long if that is the platform your compiling under. I want to keep the single source tree tradition with SB if all possible. The only issue I'm seeing in SB Win 64 is the 32 bit PRINT issue. (kings reward) SB doesn't complain with assignments of big numbers, only PRINTing them.


Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #161 on: September 08, 2014, 12:59:32 PM »
My 3G modem suddenly went down and I had to go out to buy me a new one. This one is slower than my former one but it's too late here to buy a better one. Guess I'll have to go out one more time tomorrow morning...

So why then don't you try and compile the original TS sources with MinGW GCC on 64 bits to see how its maths and print behave without modification?

JRS

  • Guest
Re: TinyScheme
« Reply #162 on: September 08, 2014, 01:05:01 PM »
Quote
So why then don't you try and compile the original TS sources with MinGW GCC on 64 bits to see how its maths and print behave without modification?

That was my first try at going 64 bit with TinyScheme. Too many errors to proceed. When I found the VS version, that renewed my hope.

SB reacts the same way as TS did using TDM-GCC-64 but compiles fine without error.

Mike Lobanovsky

  • Guest
Re: TinyScheme
« Reply #163 on: September 08, 2014, 01:15:22 PM »
So let me ask once again: does TDM-GCC refuse to compile under 64-bit Windows the original unmodified TS sources as a full-blown 64-bit application with correct 64-bit maths and print, without warnings? I don't have 64-bit GCC 4.8.1 installed under my Win 7 yet though I do have it in a zip for quite some time since I downoaded it last winter. :)

JRS

  • Guest
Re: TinyScheme
« Reply #164 on: September 08, 2014, 02:12:54 PM »
I had to remove under the Linux section of the makefile the -ldl library as there isn't a TDM-GCC equivalent. It compiled but not generating 64 bit numbers.


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));
               ^
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
 Volume in drive C has no label.
 Volume Serial Number is 0C51-A073

 Directory of C:\tinyscheme-master\src

09/08/2014  03:06 PM    <DIR>          .
09/08/2014  03:06 PM    <DIR>          ..
03/29/2014  08:33 AM             4,062 BUILDING
03/29/2014  08:33 AM            14,636 CHANGES
03/29/2014  08:33 AM             1,548 COPYING
03/29/2014  08:33 AM             3,324 dynload.c
03/29/2014  08:33 AM               281 dynload.h
09/08/2014  03:06 PM            11,003 dynload.o
03/29/2014  08:33 AM            10,490 hack.txt
03/29/2014  08:33 AM            24,511 init.scm
09/08/2014  03:06 PM           258,116 libtinyscheme.a
09/08/2014  03:06 PM           386,666 libtinyscheme.dll
09/08/2014  03:05 PM             1,995 makefile
03/29/2014  08:33 AM            17,238 Manual.txt
03/29/2014  08:33 AM             3,714 MiniSCHEMETribute.txt
03/29/2014  08:33 AM               797 mk_init_scm.scm
03/29/2014  08:33 AM               976 msvcbuild.bat
03/29/2014  08:33 AM            22,867 opdefines.h
03/29/2014  08:33 AM             5,103 scheme-private.h
03/29/2014  08:33 AM           149,655 scheme.c
09/08/2014  03:06 PM           397,031 scheme.exe
03/29/2014  08:33 AM             7,327 scheme.h
09/08/2014  03:06 PM           245,757 scheme.o
              21 File(s)      1,567,097 bytes
               2 Dir(s)  123,526,754,304 bytes free

C:\tinyscheme-master\src>scheme
TinyScheme 1.41
ts> (load "king.scm")
Loading 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   0
 field 34  number of grains   0
 field 35  number of grains   0
 field 36  number of grains   0
 field 37  number of grains   0
 field 38  number of grains   0
 field 39  number of grains   0
 field 40  number of grains   0
 field 41  number of grains   0
 field 42  number of grains   0
 field 43  number of grains   0
 field 44  number of grains   0
 field 45  number of grains   0
 field 46  number of grains   0
 field 47  number of grains   0
 field 48  number of grains   0
 field 49  number of grains   0
 field 50  number of grains   0
 field 51  number of grains   0
 field 52  number of grains   0
 field 53  number of grains   0
 field 54  number of grains   0
 field 55  number of grains   0
 field 56  number of grains   0
 field 57  number of grains   0
 field 58  number of grains   0
 field 59  number of grains   0
 field 60  number of grains   0
 field 61  number of grains   0
 field 62  number of grains   0
 field 63  number of grains   0
 field 64  number of grains   0

C:\tinyscheme-master\src>