1 / 14

Practical Issues, Odds and Ends

Practical Issues, Odds and Ends. Per Brand. Base Environment - Reference Manual. Table of Contents 1 Introduction 2 Type Structure and Description Format 3 Values 4 Numbers

cheryl
Télécharger la présentation

Practical Issues, Odds and Ends

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Practical Issues,Odds and Ends Per Brand

  2. Base Environment - Reference Manual Table of Contents 1 Introduction 2 Type Structure and Description Format 3 Values 4 Numbers 5 Literals 6 Records, Tuples, and Lists 7 Text 8 Procedures and Cells 9 Chunks 10 Control 11 Infix Notations 12 Miscellaneous Bibliography Index

  3. Base Environment • Contains a short description of all language entities (types) • Contains a short description of fundamental operations on language entities • Contains a number of useful abstractions on language entities • Part 6 - Records, tuples, lists • Many useful list/record abstractions • Part 10 - Control • What you can do with 1st class threads • Part 4 - Numbers • Arithmetical operations • Part 9- Chunks • Also arrays, dictionaries

  4. Chunks • A chunk is similar to a record except that: • .The label of a chunk is an Oz-name. • .There is no Arity operation available on chunks. • This means one can hide certain components of a chunk if the feature of the component is an Oz-name that is visible only (by lexical scoping) to user-defined operations on the chunk.

  5. Chunks II • A chunk is created by: {NewChunk Record ?Chunk}. • This creates a chunk with the same arguments as the record, but having a unique label. local X in {Browse X={NewChunk f(c:3 a:1 b:2)}} {Browse X.c}end This will display the following. • <Ch>(a:1 b:2 c:3)3

  6. Chunks-III • Chunks and cells are primitive in Oz. • Objects, classes etc. can be defined in terms of them • Interesting as the smaller the kernel of a programming system is • predictability • good properties for program analysis, etc. • For our purposes we will briefly consider arrays and dictionaries- abstractions that can be built on top of chunks

  7. Arrays • Arr={NewArray 1 100 nil} • creates an array of 100 elements indexed by 1 to 100 that are initialized to nil • {Array.put Arr 1 a} or Arr.1:=a • X={Array.get Arr 1} or X=Arr.1 • R={Array.toRecord +Label +Array} • creates a record(tuple) that is a stateless copy of the array • (you may find this useful for distribution)

  8. Dictionaries • Dict={NewDict} • creates a dictionary and association between Keys and Entries • Keys are atoms, integers, or names • Entries can be anything • {Dictionary.put Dict Key WhatEver} or Dict.Key:=WhatEver • X={Dictionary.get Dict Key} or X=Dict.Key • X={Dictionary.condGet Dict Key Default} • equivalent to Dictionary.get if there is a entry in the Dictionary for that key- otherwise X=Default • X={Dictionary.keys Dict} • returns a list of current keys • X={Dictionary.entries Dict} • returns a list of current entries of form Key#Entry • R={Dictionary.toRecord +Label +Dict} • creates a record(tuple) that is a stateless copy of the dictionary • (you may find this useful for distribution)

  9. System Modules • Part I: Application Programming • 1 Application Support: Application • 2 Module Managers: Module • need to know this • Part II: Constraint Programming • not needed for this course • Part III: Distributed Programming • will be considered later • Part IV: Open Programming • 17 Files, Sockets, and Pipes: Open • 18 Operating System Support: OS • These are just the OZ interface to OS and File system services • Read on need

  10. More System Modules • Part V: System Programming • 19 Persistent Values: Pickle • 20 Emulator Properties: Property • read for overview - read on need • 21 Error Formatting: Error • 22 System Error Formatters: ErrorFormatters • 23 Memory Management: Finalize • 24 Miscelleanous System Support: System • read for overview - details on need • Part VI: Window Programming • 25 The Module Tk • 26 Graphical Tools: TkTools • deals with graphics • you won’t need this because we have done it for you • Part VII: Miscellaneous • 27 Support Classes for Objects: ObjectSupport

  11. Pickle • A pickle is a file that represents stateless Oz graphs (transitive closure) • Any stateless value can be pickled - i.e. stored on file and retrieved from file • Stateless includes numbers, atoms, strings, procedures, classes • stateless includes both data and code • Stateless does not include cells, objects, single-assignment variables • The Mozart system consists of two parts • the engine (a virtual machine) • a number of Oz modules • all the Oz modules exist in pickled form - when you start Oz the Oz-base environment modules will be loaded eagerly and the other modules upon need (access) • The user can pickle and unpickle himself

  12. Pickles-cont’d • declareclass Registry …endclass SubRegistry from Registry…endX=[a b c d]proc{Q U} … endproc{P A B} {Q X}endY=mySave(a:SubRegistry b:[e f g] c:P}{Pickle.save Y ‘xxx’} %%% everything saved directly or %%% indirectly • declareX={Pickle.load ‘xxx’} %%% get everything

  13. Resources • Resources are references from Oz to system resources • files, file system • windows, standard input/output • Resources may not be pickled - reasons • Security • Unclear scoping - dynamic or static • dynamic - resources of loader • static - resources of saver • Instead pickle functors that are dynamically linked to resources upon loading

  14. Stand-alone - .ozf • Standalone application, file p1.oz(ozc -c p1.oz) results in the file p1.ozf functor import System Application define {System.show 'hello world'} {Application.exit 0} end • ozengine p1.ozf

More Related