exercism / common-lisp

Exercism exercises in Common Lisp.
https://exercism.org/tracks/common-lisp
MIT License
82 stars 77 forks source link

[v3] Implement new Concept Exercise: variables #310

Closed TheLostLambda closed 3 years ago

TheLostLambda commented 4 years ago

This document describes how to implement the variables concept exercise for the Common Lisp track.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Please also watch the following video:

Goal

The goal of this exercise is to familiarize students with the definition and scoping of variables in Common Lisp. Students should be able to create local, global, and constant variables and understand dynamic vs lexical scoping.

The use of earmuffs (*var*) and the equivalent convention for constants (+var+) should be encouraged, as should the use of docstrings in global definitions.

Learning objectives

Out of scope

Concepts

Prerequisites

Resources to refer to

Hints

After

Naming conventions could be explored:

Additionally, a brief exploration into the difference between defparameter and defvar could be included.

Point out that defconstant should be kept to chars, symbols, and numbers. Things that aren't eql, like lists or strings, can have their inner items mutated.

Perhaps show off what rebinding *standard-output* looks like and how it can be used to neatly build up strings.

Representer

Analyzer

Implementing

To ensure that students are using docstrings, you can use the documentation function in the test-suite.

Using defconstant may cause issues if the student reloads there code with a new value. This should be mentioned in the instruction.md or introduction.md so that the student is made aware of this pitfall and can avoid it.

When demonstrating dynamic variables, save rebinding *standard-output* for the after.md. It's a good example, but requires an understanding of streams first, which the student is not guaranteed to have.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

verdammelt commented 4 years ago

I think defconstant will need to be handled carefully in this exercise. If we have the student define it they would easily get into a state where they reload their solution file and get dropped into the debugger because the value is not eql. I think we could explain the situation in instruction.md - but perhaps we should call this out in "implementing" as something that needs handling.

verdammelt commented 4 years ago

Also there is mention that *standard-output* is out of scope but is mentioned in "Implementing" as something to use as an example... can we clarify this potential contradiction?

TheLostLambda commented 4 years ago

I've added a note about defconstant thanks for pointing that out! Additionally, I've tweaked the wording a bit. I think it would be okay to show off in the after.md but we should probably not teach streams in this exercise or expect the student to know them already. Let me know if that helps clarify any!

verdammelt commented 4 years ago

That is definitely clearer to me thanks.