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

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

There are two background issues here:

  1. No string data-type.
  2. How Euphoria works with text: internal, raw input, files.

Explaining item two will take some time. For now, does this explain item one?

Text Data

Text is "data composed of characters or strings of characters."

When designing a computer language you choose (and compromise) how text will be represented and processed.

Binary operator Language Example
space Snobol

dog = 'K' 9
--> K9 
+ Python

dog = 'K' + 9
--> TypeError: Can't convert 'int' object to str implicitly 
& Euphoria

object dog = 'K' & 9
-->{75,9}  
+ Euphoria

dog = 'K' + 9
--> 84 

The lesson is: learn more than one language and pick the tool that best matches your current problem.

Snobol was designed to work with text. That is why a character 'K' and a number 9 concatenate to form a string. In a language designed to process strings a blank space is a very convenient concatenation operator.

Python was designed to isolate text and numbers using separate data-types. That means you can not mix a character 'K' and a number 9 and get a result. In Python a + adds numbers but + concatenates strings. In a language designed to teach programming the isolation of text and numbers can be a good thing.

Euphoria was designed so that all data is an object and objects are composed of numbers. That means 'K' is the number 75. That means there is no conflict in concatenating two numbers to form a two element sequence. That means there is no conflict in adding two numbers to form a sum. In a language designed to be flexible this is a good thing.

Euphoria lets you choose how to display an object value:

print(1, 'K') 
    --> 84 
puts(1, 'K' ) 
    --> K 

In Euphoria 'K' is always converted into the number 84; you then choose to display 84 as a number or as a character.

"Euphoria has no string data-type" means all character values are encoded as numbers. It turns out you can read text files, use literal text in expressions, and conveniently display text without remembering that you are just working with an object composed of numbers. Often Euphoria behaves the same as languages that have string data-types; this makes Euphoria simple.

Euphoria was designed to be simple and flexible.

  • The same operators and routines work on all data--text or numbers.
  • You have the freedom to do anything with your data.
  • The cost of flexibility is you have to take responsibility for your data.

For example. You can always display a Euphoria object as text or as numbers; however Euphoria can not know what you want to see. Actually, console:display does a good job in distinguishing numbers used as text from numbers used as numbers --but not always. Contrast this with a language that does have a string data-type; text is always displayed as text but you do not have the flexibility to display and process text in any way you choose.

_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu