Re: OK what does ` mean - seriously seems to be not documented.

new topic     » goto parent     » topic index » view thread      » older message » newer message
gimlet said...

'A' + 'B' is nonsense 65 + 66 is not. Their representations are the same (and in Euphoria presumably if you wrote c = 'A' + 'B' then c would be assigned 131) - but shouldn't that be nonsense?

One of Euphoria's main attributes is it's tiny set of built-in datatypes. Anything more complex that scalars (atoms/integers) and lists (sequences) are the responsibility of the programmer and not the language. This is something we have to come to terms with and once one does, it is quite liberating.

Here is another example of nonsense that is the programmer's responsibility - and this also applies to some other languages as well.

enum 
  RED, 
  BLUE, 
  YELLOW, 
  GREEN, 
  ORANGE, 
  PURPLE, 
  BROWN, 
  WHITE, 
  BLACK 
 
     set_color(Field, RED    + BLUE)       -- Is the field now purple or yellow? 
     set_color(Field, RED    + YELLOW)     -- Is the field now orange or green? 
     set_color(Field, YELLOW + BLUE)       -- Is the field now green or orange? 
     set_color(Field, YELLOW + BLUE + RED) -- Is the field now white or purple? 

Ok, if that's a problem then try this modification ...

enum  
  RED = 1, 
  BLUE = 2, 
  YELLOW = 4, 
  GREEN = 6, 
  ORANGE = 5, 
  PURPLE = 3, 
  BROWN = 8, 
  WHITE = 7, 
  BLACK = 0 
 
     set_color(Field, RED    + BLUE)       -- Purple 
     set_color(Field, RED    + YELLOW)     -- Orange 
     set_color(Field, YELLOW + BLUE)       -- Green 
     set_color(Field, YELLOW + BLUE + RED) -- White 

So, is the concept of adding colors nonsense? No. The limitation comes with having colors represented by numbers (ORANGE + GREEN != BROWN) ... just as there are also limitations when numbers represent characters, such as 65 represents 'A'.

It is our responsibility as Euphoria programmers to manage these limitations.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu