error in let function

Started by eddier, November 14, 2003, 11:00:55 AM

Previous topic - Next topic

eddier

I'm pulling from a comma separated file.



"L" looks like '(""AR335-A"",""3.00"",""Sur.Art Hist./Appre."",""8:00"",""8:50"",""M W F"",""A"",""35"",""DOWDY"")



(define (get-period L)
  (let ((l (append (trim (nth 3 L) {"}) "-" (trim (nth 4 L) {"}))))
    l))


gives a segmentation fault



(define (get-period L , l)
  (setq l (append (trim (nth 3 L) {"}) "-" (trim (nth 4 L) {"}))))


works fine.  I wonder if there is a problem in the "let" function.  However, I have several "let"s through out the program that are giving any problem.



Eddie

Lutz

#1
I cannot repeat the crash, instead I am getting the following error on both functions.



string expected : (nth 3 L)

called from user defined function get-period



Because the third element of L is a comma, not a string



(on version 7.3.1)



Lutz

eddier

#2
I made the mistake of copying and pasting the csv record without deleting the commas.



Should be no commas in the list.



Eddie

Lutz

#3
Thanks Eddie for catching this. It happened when returning from 'let' one of it's local vars. This is fixed and will be in the development release on this weekend.



This bug was in there since 'let's introduction 3 years ago, and nobody else seems to have run into it :-)



Actually you could have just returned the result of 'append'



(define (get-period L)

    (append (trim (nth 3 L) {"}) "-" (trim (nth 4 L) {"})))



perhaps this was just a snippet from a bigger portion of code.



Lutz

eddier

#4
Quote
perhaps this was just a snippet from a bigger portion of code.


Yes.  I needed a local variable to keep up with the time a period began and ended. I'm going to use the local variable in a case statement.



I've used a bunch of let statements before without this kind of error. Subtle bug!



Eddie[/quote]

Lutz

#5
The bug has been fixed! I forgot to mention that in the changes file.



Lutz