jimmysnielsen
2019-5-7 08:36:17

Two questions on using scribble/base. first question. how do I insert a newline in an @title{xx}. I want to do something like “Memo - some text here” “By - my initials” The following does not get me what I want: #lang scribble/base @title{text 1 text 2} @section{text1} xxx @section{text2} xxx —- It renders as “text 1 text 2” *** Second question I tried @title{text 1

   text 2}

@section{text1} xxx @section{text2} xxx

->with an added line in the @title section <- And I got a LOT! of warnings and it didnt render.


mflatt
2019-5-7 13:54:05

Use @linebreak[] to create a line break within a title. Or maybe you want to use @author after @title. I see what you mean about the Latex error when you include a blank line, and we should adjust Scribble to avoid that. (Latex is really uncooperative as a back end.)


soegaard2
2019-5-7 20:27:05

let/defaults


soegaard2
2019-5-7 20:27:18

where / is short for “with”


ruyvalle
2019-5-8 00:18:08

hello, I’ve been reading through Rash’s source code and found something of the following form: (let () &lt;body&gt;)

is there a purpose to a let that doesn’t introduce any bindings? I can’t seem to figure this out from the documentation.

Thank you!


sorawee
2019-5-8 01:16:02

I think it’s mostly used to introduce the internal definition context.

If you have (if &lt;e1&gt; &lt;e2&gt; &lt;e3&gt;), and in &lt;e2&gt; you want to use define, you might attempt this:

(if #t
    (begin
       (define x 1)
       x)
    #t)

But this results in an error because define doesn’t work in the expression context. However, you can do this:

(if #t
    (let ()
      (define x 1)
      x)
    #t)

Because the body of let allows internal-definition, this works as expected


sorawee
2019-5-8 01:27:03

Would it be better if I simply make it completely compatible with let and call it let+? But otherwise I think I’m gonna stick with loop, as it’s only 4 character long.


greg
2019-5-8 01:33:39

@ruyvalle I think @sorawee is right about why that code does that. Also, the Racket style guide suggests using cond instead of if. Various reasons why. Relevant one, here: You could just write: (cond [#t (define x 1) x] [else #t])



sorawee
2019-5-8 01:58:40

Yup, I rarely use if because of this reason.

In fact, I think that it’s generally a bad style to write (let () ...) directly in your code. The only place I think it makes sense to use is in macros. For example, if you want to define your own cond, here’s one possibility (though pretty crappy)

(define-syntax-parser cond*
  #:literals (else)
  [(_) #'(void)]
  [(_ [else . body]) #'(let () . body)]
  [(_ [test-expr . body] . rest)
   #'(if test-expr (let () . body) (cond* . rest))])

greg
2019-5-8 03:29:03

I agree. Well. Sometimes that’s the least-worst choice I’ve found when writing certain rackunit tests.


ruyvalle
2019-5-8 04:31:37

great! thank you so much @sorawee and @greg!