Three options:

1) Implement your language in `#lang br` now (and optionally convert to 
`racket/base` later) [1]

2) Import the `br/datum` module into a `#lang racket/base` program to get 
`format-datum` [2]

3) Reimplement `format-datum` your own way. You can see the underlying code by 
right-clicking on `format-datum` in DrRacket and selecting "Open Defining File".

[1] https://beautifulracket.com/appendix/from-br-to-racket-base.html
[2] 
https://docs.racket-lang.org/br/index.html?q=br%2Fdatums#%28mod-path._br%2Fdatum%29

> On Apr 10, 2020, at 9:17 AM, Pratyush Das <reik...@gmail.com> wrote:
> 
> A followup question - 
> 
> But this assumes that the br lang is being used(I think because of the 
> format-datum syntax). How do I implement this without using the br lang?
> 
> ...
> (define 
> <http://docs.racket-lang.org/reference/define.html#(form._((lib._racket/private/base..rkt)._define))>
>  src-lines (port->lines 
> <http://docs.racket-lang.org/reference/port-lib.html#(def._((lib._racket/port..rkt)._port-~3elines))>
>  port))
>   (define 
> <http://docs.racket-lang.org/reference/define.html#(form._((lib._racket/private/base..rkt)._define))>
>  src-datums (format-datums 
> <http://docs.racket-lang.org/br/index.html#(def._((lib._br/datum..rkt)._format-datums))>
>  '(handle ~a) src-lines))
> ...
> 
> Is it possible to use modules to just get the format-datums from the br 
> language? 
> 
> 
> On Fri, 10 Apr 2020 at 17:50, Pratyush Das <reik...@gmail.com 
> <mailto:reik...@gmail.com>> wrote:
> I am absolutely new to both Racket and language implementation.
> 
> I read through some portions of Beautiful Racket 
> <https://docs.racket-lang.org/guide/languages.html> and the racket guide 
> <https://docs.racket-lang.org/guide/languages.html> before trying to 
> implement a language on my own and this is what I understand - 
> 
> I created a main.rkt which would be the boot module in my source directory, 
> following the Beautiful Racket master recipe 
> <https://beautifulracket.com/appendix/master-recipe.html>.
> 
> Every language should define and provide a read-syntax function. 
> 
> To make the new language read the source file, read-syntax must be defined 
> something like - 
> (define (read-syntax path port)
> ...)
> 
> Like in Beautiful Racket's wires language implementation 
> <https://beautifulracket.com/wires/intro.html>, I want to read the source 
> file line by line and wrap it in a macro. 
> Beautiful Racket does it like this - 
>   (define 
> <http://docs.racket-lang.org/reference/define.html#(form._((lib._racket/private/base..rkt)._define))>
>  (read-syntax 
> <http://docs.racket-lang.org/reference/Reading.html#(def._((quote._~23~25kernel)._read-syntax))>
>  path port)
>     (define 
> <http://docs.racket-lang.org/reference/define.html#(form._((lib._racket/private/base..rkt)._define))>
>  wire-datums
>       (for/list 
> <http://docs.racket-lang.org/reference/for.html#(form._((lib._racket/private/base..rkt)._for/list))>
>  ([wire-str (in-lines 
> <http://docs.racket-lang.org/reference/sequences.html#(def._((lib._racket/private/base..rkt)._in-lines))>
>  port)])
>         (format-datum 
> <http://docs.racket-lang.org/br/index.html#(def._((lib._br/datum..rkt)._format-datum))>
>  '(wire ~a) wire-str)))
> 
> But this assumes that the br lang is being used(I think because of the 
> format-datum syntax). How do I implement this without using the br lang?
> 
> Also, am I wrong in any of my assumptions so far?
> 
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Racket Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/racket-users/qEXz8YcAisc/unsubscribe 
> <https://groups.google.com/d/topic/racket-users/qEXz8YcAisc/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> racket-users+unsubscr...@googlegroups.com 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/180aae4b-9e79-43cc-9177-6c917acf0dc8%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/racket-users/180aae4b-9e79-43cc-9177-6c917acf0dc8%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> Pratyush Das(Reik)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com 
> <mailto:racket-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAFzLTskQ70okYZj247VA2rGNWyoW62wCyyu3jqXHtzZdw3aJEg%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/racket-users/CAFzLTskQ70okYZj247VA2rGNWyoW62wCyyu3jqXHtzZdw3aJEg%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/92CD2147-DC05-44C5-A262-3792CD32FDDF%40mbtype.com.

Reply via email to