home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.os.vms      DEC's VAX* line of computers & VMS.      264,096 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 262,316 of 264,096   
   =?UTF-8?Q?Arne_Vajh=C3=B8j?= to All   
   Re: basic BASIC question   
   31 Jan 25 20:39:22   
   
   From: arne@vajhoej.dk   
      
   On 1/31/2025 8:38 PM, Arne Vajhøj wrote:   
   > On 1/31/2025 5:05 PM, Dan Cross wrote:   
   >> In article <679d26bd$0$713$14726298@news.sunsite.dk>,   
   >> Arne Vajhøj   wrote:   
   >>> But there is no consistency between languages.   
   >>>   
   >>> $ type dump.for   
   >>> [snip]   
   >>   
   >> I don't know why this should be surprising?   
   >   
   > I don't know if it is surprising, but it is inconsistent.   
   >   
   >                   Fortran       Pascal          
   C          Basic   
   > true literal       -1             1      usually   
   1    usually -1   
   > false literal       0             0            
   0            0   
   > test            low bit set  low bit set   not 0          
   not 0   
   >   
   > 4 languages - 4 ways of doing it.   
      
   Regarding the test:   
      
   $ type m.pas   
   program m(input,output);   
      
   type   
       ia5 = array [1..5] of integer;   
      
   [external]   
   procedure b(%ref v : ia5); external;   
      
   var   
       v : ia5;   
      
   begin   
       v[1] := -2;   
       v[2] := -1;   
       v[3] := 0;   
       v[4] := 1;   
       v[5] := 2;   
       b(v);   
   end.   
   $ type b.bas   
   sub b(integer v() by ref)   
        external string function s(integer)   
        external sub f(integer dim() by ref)   
        print using "Basic   : 'E 'E 'E 'E 'E", s(v(0)), s(v(1)), s(v(2)),   
   s(v(3)), s(v(4))   
        call f(v())   
   end sub   
   !   
   function string s(integer v1)   
        if v1 then   
            s = "TRUE "   
        else   
            s = "FALSE"   
        end if   
   end function   
   $ type f.for   
          subroutine f(v)   
          logical*4 v(5)   
          write(*,'(1x,a,5(l,4x))') 'Fortran :',v(1),v(2),v(3),v(4),v(5)   
          call c(v)   
          end   
   $ type c.c   
   #include    
      
   void p(int *v);   
      
   void c(int *v)   
   {   
        printf("C       :");   
        for(int i = 0; i < 5; i++) {   
            if(v[i]) {   
                printf(" TRUE ");   
            } else {   
                printf(" FALSE");   
            }   
        }   
        printf("\n");   
        p(v);   
   }   
   $ type p.pas   
   module p(input, output);   
      
   type   
       ia5 = array [1..5] of boolean;   
      
   [global]   
   procedure p(v : ia5);   
      
   begin   
       writeln('Pascal  : ', v[1]:1, '     ', v[2]:1, '     ', v[3]:1, '   
     ', v[4]:1, '     ', v[5]:1);   
   end;   
      
   end.   
   $ pas m   
   $ bas b   
   $ for f   
   $ cc c   
   $ pas p   
   $ link m + b + f + c + p   
   $ run m   
   Basic   : TRUE  TRUE  FALSE TRUE  TRUE   
   Fortran : F     T     F     T     F   
   C       : TRUE  TRUE  FALSE TRUE  TRUE   
   Pascal  : F     T     F     T     F   
      
   Arne   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca