typesozmozart

Mozart-Oz difference between String and Atom


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


Solution

  • 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