Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why does (READ-FROM-STRING “foobar” :START 3) return FOOBAR instead of BAR?

0
Posted

Why does (READ-FROM-STRING “foobar” :START 3) return FOOBAR instead of BAR?

0

READ-FROM-STRING is one of the rare functions that takes both &optional and &key arguments.

0

\cl{READ-FROM-STRING} is one of the rare functions that takes both

0

READ-FROM-STRING is one of the rare functions that takes both &OPTIONAL and &KEY arguments: READ-FROM-STRING string &OPTIONAL eof-error-p eof-value &KEY :start :end :preserve-whitespace When a function takes both types of arguments, all the optional arguments must be specified explicitly before any of the keyword arguments may be specified. In the example above, :START becomes the value of the optional EOF-ERROR-P parameter and 3 is the value of the optional EOF-VALUE parameter. To get the desired result, you should use (read-from-string “foobar” t nil :start 3). If you need to understand and use the optional arguments, please refer to CLTL2 under READ-FROM-STRING, otherwise, this will behave as desired for most purposes. The other functions with this peculiarity in the COMMON-LISP package are PARSE-NAMESTRING, WRITE-LINE and WRITE-STRING.

0

READ-FROM-STRING is one of the rare functions that takes both &OPTIONAL and &KEY arguments: READ-FROM-STRING string &OPTIONAL eof-error-p eof-value &KEY :start :end :preserve-whitespace When a function takes both types of arguments, all the optional arguments must be specified explicitly before any of the keyword arguments may be specified. In the example above, :START becomes the value of the optional EOF-ERROR-P parameter and 3 is the value of the optional EOF-VALUE parameter. To get the desired result, you should use (READ-FROM-STRING “foobar” t nil :START 3) If you need to understand and use the optional arguments, please refer to CLTL2 under READ-FROM-STRING, otherwise, this will behave as desired for most purposes.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123