spdegabrielle
2019-8-8 09:18:13

Are interested in contributing to Racket while learning? Try you can try your hand at issues tagged ‘good first issue’ or good first bug’. e.g racket- good-first-issue - https://github.com/racket/racket/issues?q=is%3Aopen+is%3Aissue+label%3Agood-first-issue typed-racket good-first-issue - https://github.com/racket/typed-racket/issues?q=is%3Aopen+is%3Aissue+label%3Agood-first-bug racket/math good first issue - https://github.com/racket/math/labels/good%20first%20issue If you have trouble don’t be shy about asking for help either here on slack or on the email list.


zacromero3
2019-8-8 09:20:46

@zacromero3 has joined the channel


spdegabrielle
2019-8-8 14:52:35

FYI https://github.com/topics/racket shows issues that are labelled good first issue or good first bug in repositories that have the racket topic


samth
2019-8-8 17:21:42

@sanchom is there an easy way to do that with the github api?


samth
2019-8-8 17:56:30

ok done


sydney.lambda
2019-8-8 18:33:57

I asked for some help a while back regarding a 6502 simulator. Lexi Lambda very kindly provided a solution, but after a number of attempts I just can’t wrap my head around it due to my inexperience with macros. I was hoping someone could please have a look over my more rudimentary idea, and see if they can spot any glaring problems.

The first step (or, imagined first step) is parsing the assembly to produce a tree, but I’m skipping that for now and just providing a tree directly: '(( LDX $00 ) ( LDA $00 ) ( BEQ NOTZERO) ( LDX $2A ) (NOTZERO: LDA $00 ))) Then, for the next step, walking the tree and labelling it — if the line has no user-defined label, a fresh label is created using gensym. Any user-defined labels encountered will be replaced with a gensym label and added to a hash of ([USER-LABEL . GENSYM-LABEL]): '((g0 LDX 00) (g1 LDA 00) (g2 BEQ NOTZERO) (g3 LDX 42) (g4 LDA 00)) and a hash: ([NOTZERO . g4]) Then, finally, a big letrec is constructed for the actual program, with all procedures taking a processor/memory state and returning a new one, which is passed to the next label number. For branches, we consult the dictionary produced in the previous step: (letrec ([g0 (λ (st) (LDX #x00 (g1 st)))] [g1 (λ (st) (LDA #x00 (g2 st)))] [g2 (λ (st) (BEQ (g4 st) (g3 st)] ; when expanding a branch, look up the label in the dictionary [g4 (λ (st) (LDA #x00 identity))]) ; final instruction uses identity as the continuation (g0 initial-processor-state)) With BEQ taking two arguments, the continuation if we take the branch, and the continuation if we don’t which is just the next label in numerical order. The other solution of course is do it like an actual emulator, assembling the opcodes to bytes, storing them in a vector, and then running through them using a PC. I wanted to do this as an exercise as I felt rather defeated being unable to comprehend the macro.

Any glaring errors in my plan? Thanks :slightly_smiling_face:


soegaard2
2019-8-8 19:02:34

Use string->symbol not gensym


soegaard2
2019-8-8 19:03:52

Potential problem: self-modifying code


soegaard2
2019-8-8 19:05:16

(Btw - an emulator is normally written as a function, not a macro)


sydney.lambda
2019-8-8 19:16:53

I mean, Lexi wrote a macro which defined the labels so you could have forward references. I’m writing a regular emulator using a vector with a PC and such too, but I wanted to see if I could write a simulator in Racket without using macros. I hadn’t considered self-modifying code, so I’ll have to think on that. I don’t think it’s possible at all with this design, sadly. Thanks @soegaard2


sydney.lambda
2019-8-8 19:17:50

The macro created by Lexi Lambda:(define-syntax-parser program [(_ start-op:expr ... {~seq #:label label:id labeled-op:expr ...} ...) #:with [block-defn ...] (for/list ([ops (in-list (cons (attribute start-op) (attribute labeled-op)))] [label (in-list (cons #f (attribute label)))] [next-label (in-list (append (attribute label) (list #f)))]) #`(define (#,(or label #'START) state) #,(if next-label #`(#,next-label (processor-do state #,@ops)) #`(processor-do state #,@ops)))) #`(let () block-defn ... (START initial-state))]) (define-syntax-parser processor-do [(_ state:expr) #'state] [(_ state:expr op0:expr op:expr ...) #'(op0 state (λ (state*) (processor-do state* op ...)))])


samdphillips
2019-8-8 20:19:22

Really what Lexi gave you is a compiler from ASM to Racket.


jay.somedon
2019-8-8 20:58:32

@jay.somedon has joined the channel


sydney.lambda
2019-8-8 20:59:03

I understand the big picture of what it does (after much chin-scratching), but keeping how it does it in my head, along with all the other nuances is far too advanced for me at the moment sadly. Soegaard2 practically had to hold my hand whilst I wrote a match-expander yesterday for crying out loud! :stuck_out_tongue:

I’ll come back to it in the future, but I just wanted to try and solve it myself as I felt a bit disheartened. I’m satisfied enough with the solution I think (as much as one can be without actually coding it in its entirety), self-modifying code aside. (define (emulate processor [PC 0]) (if (>= PC (vector-length (Processor-MEM processor))) processor (match processor [(struct* Processor ([A A] [X X] [Y Y] [Z Z] [N N] [MEM MEM])) (case (vector-ref MEM PC) [(#xA9) (emulate (struct-copy Processor processor [A (vector-ref MEM (add1 PC))]) (+ PC 2))] [(#xA2) (emulate (struct-copy Processor processor [X (vector-ref MEM (add1 PC))]) (+ PC 2))] [(#xF0) (emulate processor (if (false? Z) (+ PC 2) (let ([offset (vector-ref MEM (add1 PC))]) (if (< offset 127) (+ PC offset 2) (+ PC (- offset 256) 2)))))])]))) emulating it looks as though it’s going to be a much easier (though by no means easy) task :slightly_smiling_face:


spdegabrielle
2019-8-8 21:16:43

@sanchom @samth you can also use search to indentify issues with label ‘good first issue’ https://github.com/search?l=&o=desc&q=label%3A%22good+first+issue%22+state%3Aopen+language%3ARacket&s=updated&type=Issues


spdegabrielle
2019-8-8 21:36:49

@sanchom @samth racket repos use different labels for the same thing ‘good-first-issue’ racket/racket, racket/drracket ‘good-first-bug’ typed-racket label:“good first issue” racket/math bug or ’help wanted racket/gui webserver

if you have /contribute at the end of your repo address it does seem to pick up most https://github.com/racket/racket/contribute

that aside I’d suggest normalizing repos to use the same tags for good first issues - if you create a new repo is automatically (for me at least) creates the label good first issue with no hypens.


spdegabrielle
2019-8-8 21:37:09

to make searching easier.