Extending arithmetic

Per Bergqvist per@REDACTED
Sat Feb 8 07:21:51 CET 2003


Yes and if this is not only implmented as syntactic sugar this would  
give the emulator a chance to use SIMD instructions (MMX, SIMD, SIMD2,
VIS, MVI etc) to get killer performance.                              
This sounds like a nice little Björn or Tony hack.                    
                                                                      
/Per                                                                  
                                                                      
>                                                                     
> On fredag, feb 7, 2003, at 17:59 Europe/Stockholm, James Hague      
wrote:                                                                
>                                                                     
> > In graphics work vector math comes up a lot, and it occurred to me
                                                                      
> > that much                                                         
> > of this can be done in Erlang without changing the syntax at all. 
                                                                      
> > Rather                                                            
> > than simply allowing "number + number -> number," allow the       
following:                                                            
> >                                                                   
> > tuple + number -> tuple                                           
> > ex: {1,2,3} + 4 -> {4,6,7}                                        
> >                                                                   
> > tuple + tuple -> tuple                                            
> > ex: {1,2,3} + {4,5,6} -> {5,7,9}                                  
> >                                                                   
> > -tuple -> tuple                                                   
> > -{1,2,3} - {-1,-2,-3}                                             
> >                                                                   
> ....                                                                
> > I don't expect this to be taken seriously, but I think it's an    
> > interesting                                                       
> > idea.                                                             
>                                                                     
> Why not also add support for matrixes (when we are already          
overloading                                                           
> +, -, / and *), so that we can do things like this:                 
>                                                                     
> X = ... % current x coordinate                                      
> Y = ... % current x coordinate                                      
> Dy = ... % move along y axis                                        
> Dx = ... % move along x axis                                        
>                                                                     
> % Translated_along_X_and_Y                                          
> {X2, Y2, 1} =                                                       
> {{1,0,Dx},                                                          
> {0,1,Dy},                                                           
> {0,0,1}} * {X,Y,1}                                                  
>                                                                     
> I would assume that applications like Wings could benefit from this.
>                                                                     
=========================================================             
Per Bergqvist                                                         
Synapse Systems AB                                                    
Phone: +46 709 686 685                                                
Email: per@REDACTED                                                   



More information about the erlang-questions mailing list