Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > pt.comp.programacao > #201
| From | Patricia Ferreira <pferreira@example.com> |
|---|---|
| Newsgroups | pt.comp.programacao |
| Subject | Re: sobre NIL |
| Date | 2024-01-28 12:54 -0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <87h6ixxxll.fsf@example.com> (permalink) |
| References | <875xzezi84.fsf@example.com> <87le89zjnf.fsf@brilhante.top> |
Daniel Cerqueira <dan.list@brilhante.top> writes:
> Patricia Ferreira <pferreira@example.com> writes:
>
>> E aí, Daniel? Qual seu relato da opinião-comp.lang.lisp sobre NIL? :-)
>
> Gostei das respostas do Madhu,
Tem um erro de digitação lá no Madhu.
``(consp nil) has to be true. NIL cannot be of type CONS.''
Ele quer dizer (consp nil) tem que ser *falso*. Tem que ser falso pra
que a gente possa distingui-lo de uma célula cons verdadeira. O tipo
Lista é matematicamente definido:
--8<---------------cut here---------------start------------->8---
Definição. Uma Lista é
- NIL ou...
- (cons <ANY-TYPE> Lista)
--8<---------------cut here---------------end--------------->8---
Assim, qualquer procedimento que consome uma lista tem a forma
(defun p (ls)
(cond ((null ls) 'something)
((consp ls) (car ls) (p (cdr ls)))))
Se NIL for um /cons/, não conseguimos distinguir o fim do não-fim.
A linguagem Common Lisp não determina como NIL realmente é por baixo dos
panos porque seria muita intromissão na implementação. E tanto faz,
desde que NIL não seja um CONS pra não estragar isso tudo aí.
Observe que Kaz Kylheku não está errado, não. Você pode, sim,
implementar NIL como se fosse uma célula CONS desde que (consp NIL) não
seja verdadeiro, o que pode ser feito olhando o conteúdo da célula e
vendo se ela satisfaz a definição de NIL. (Tem nada de muito importante
aqui, não.)
Back to pt.comp.programacao | Previous | Next — Previous in thread | Next in thread | Find similar
sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-27 16:31 -0300
Re: sobre NIL Daniel Cerqueira <dan.list@brilhante.top> - 2024-01-28 13:12 +0000
Re: sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-28 12:36 -0300
Re: sobre NIL Daniel Cerqueira <dan.list@brilhante.top> - 2024-01-28 17:36 +0000
Re: sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-28 22:18 -0300
Re: sobre NIL Daniel Cerqueira <dan.list@brilhante.top> - 2024-01-29 12:19 +0000
Re: sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-29 11:17 -0300
Re: sobre NIL Daniel Cerqueira <dan.list@brilhante.top> - 2024-01-29 20:53 +0000
Re: sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-29 20:19 -0300
Re: sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-28 12:54 -0300
Re: sobre NIL Daniel Cerqueira <dan.list@brilhante.top> - 2024-01-28 17:46 +0000
Re: sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-28 22:23 -0300
Re: sobre NIL Patricia Ferreira <pferreira@example.com> - 2024-01-29 11:32 -0300
Re: sobre NIL Daniel Cerqueira <dan.list@brilhante.top> - 2024-01-29 20:53 +0000
csiph-web