08.02.2015 Views

Programação Funcional e Concorrente com Scheme

Programação Funcional e Concorrente com Scheme

Programação Funcional e Concorrente com Scheme

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

notas de aula - Jerônimo C. Pellegrini<br />

7.5 Problemas <strong>com</strong>uns a todos os sistemas de macro . . . . . . . . . . . . . . . 181<br />

7.5.1 Número de avaliações . . . . . . . . . . . . . . . . . . . . . . . . . . . 181<br />

7.5.2 Tipos de variáveis e seus valores . . . . . . . . . . . . . . . . . . . . . 183<br />

7.6 Quando usar macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183<br />

7.7 Abstração de dados <strong>com</strong> macros . . . . . . . . . . . . . . . . . . . . . . . . . 185<br />

7.8 Exemplo: Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190<br />

7.9 Casamento de padrões . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192<br />

8 Continuações 195<br />

8.1 Definindo continuações . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195<br />

8.1.1 Contextos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196<br />

8.1.2 Procedimentos de escape . . . . . . . . . . . . . . . . . . . . . . . . . 197<br />

8.1.3 Continuações . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198<br />

8.1.4 Exemplos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199<br />

8.2 Um exemplo simples: escapando de laços . . . . . . . . . . . . . . . . . . . . 200<br />

8.3 Extensão dinâmica e dynamic-wind . . . . . . . . . . . . . . . . . . . . . . . 201<br />

8.4 Sistemas de exceções . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204<br />

8.5 Co-rotinas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207<br />

8.6 Multitarefa não-preemptiva . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210<br />

8.7 O GOTO funcional e cuidados <strong>com</strong> continuações . . . . . . . . . . . . . . . 211<br />

8.8 Não-determinismo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213<br />

8.9 Estilo de passagem de continuações (opcional) . . . . . . . . . . . . . . . . . 213<br />

9 Preguiça 215<br />

9.1 Delay e force . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215<br />

9.1.1 Como implementar delay e force . . . . . . . . . . . . . . . . . . . . . 217<br />

9.2 Estruturas infinitas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219<br />

9.3 Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221<br />

9.4 Estruturas de dados <strong>com</strong> custo amortizado . . . . . . . . . . . . . . . . . . . 223<br />

9.5 Problemas <strong>com</strong> delay e force . . . . . . . . . . . . . . . . . . . . . . . . . . . 224<br />

10 Concorrência 225<br />

10.1 Problemas inerentes à Programação <strong>Concorrente</strong> . . . . . . . . . . . . . . . 227<br />

10.1.1 Corretude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227<br />

10.1.2 Dependência de velocidade . . . . . . . . . . . . . . . . . . . . . . . . 228<br />

Versão Preliminar<br />

10.1.3 Deadlocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230<br />

10.1.4 Starvation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233<br />

10.2 Problemas e exemplos típicos . . . . . . . . . . . . . . . . . . . . . . . . . . . 235<br />

10.2.1 Produtor-consumidor . . . . . . . . . . . . . . . . . . . . . . . . . . . 235<br />

iv<br />

[ 27 de outubro de 2010 at 15:47 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!