Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > pt.comp.programacao > #201

Re: sobre NIL

Path csiph.com!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Patricia Ferreira <pferreira@example.com>
Newsgroups pt.comp.programacao
Subject Re: sobre NIL
Date Sun, 28 Jan 2024 12:54:14 -0300
Organization A noiseless patient Spider
Lines 39
Message-ID <87h6ixxxll.fsf@example.com> (permalink)
References <875xzezi84.fsf@example.com> <87le89zjnf.fsf@brilhante.top>
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Injection-Info dont-email.me; posting-host="13f7e7521e41d02a855f3836a0f67ed7"; logging-data="8179"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Mpv661QgAzIYpXn0cq1lz98qaMwM71xc="
Cancel-Lock sha1:0gQTj2FZfHdUQklV90f3wv/OvZo= sha1:AwJHtL1IOtne80CJaHsNJd26LAU=
Xref csiph.com pt.comp.programacao:201

Show key headers only | View raw


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 | NextPrevious in thread | Next in thread | Find similar


Thread

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