2

Could anyone provide a concise explanation of the difference between String and Atom types in the Oz programming language? I found the documentation lacking.

  • If I'm not mistaken `sting` is a list containing characters, while `atom` is an empty record (record with a label but without components). – vonaka Oct 06 '18 at 22:10

1 Answers1

2

This is the type hierarchy shown in the CTM book. The type hierarchy

According to this, an atom is a kind of record. Unlike other kinds of records, atoms do not have an internal structure. A string is just syntactic sugar for a list, and as such, will have all the other properties of a list, such as getting represented in terms of Head|Tail, terminated by nil, etc.

You can play around with these two examples to further your understanding:

{Browse 'hello'==hello} % prints true, neither is a string

{Browse "hello"==[104 101 108 108 111]} % prints true, equivalent representations of the same string

{Browse 'hello'=="hello"} % prints false
prash
  • 324
  • 3
  • 14