---
# System prepended metadata

title: Y'all Lang Discussion

---

# Y'all Lang Discussion

## Structs

* [Racket](https://docs.racket-lang.org/reference/define-struct.html)

### Declaring

```lisp
(struct Friend (
    name::String
    birthday::Date
    is-cool::bool
))

(struct Friend (
    name :: String
    birthday :: Date
    is-cool :: bool
))

(struct Friend (
    ::String name
    ::Date birthday
    ::bool is-cool
))
```

### Creating

```lisp
(let jordan (Friend 
    name: "Jordan" birthday: (Date (year: 1991 month: 1 day: 1)) is-cool: true))
    
(let jordan (Friend 
    (name:"Jordan" birthday:(Date (year:1991 month:1 day:1)) is-cool:true)))
    
(let charlie (Friend 
    name: "Charlie" 
    birthday: (Date (year: 1991 month: 1 day: 1)) 
    is-cool: true))
    
(let charlie (Friend 
    name:"Charlie" 
    birthday:(Date (year:1991 month:1 day:1)) 
    is-cool: true))
```

```lisp
(let jordan (Friend 
    name="Jordan" birthday=(Date (year=1991 month=1 day=1)) is-cool=true))
    
(let jordan (Friend 
    name = "Jordan" birthday = (Date (year = 1991 month = 1 day = 1)) is-cool = true))
    
(let charlie (Friend 
    name="Charlie"
    birthday=(Date (year = 1991 month = 1 day = 1))
    is-cool=true))
    
(let charlie (Friend 
    name = "Charlie"
    birthday = (Date (year = 1991 month = 1 day = 1))
    is-cool = true))

; commas?
(let charlie (Friend 
    name = "Charlie",
    birthday = (Date (year = 1991, month = 1, day = 1)),
    is-cool = true))
```

```lisp
(let charlie (Friend 
    :name "Jordan" :birthday (Date (:year 1990 :month 1 :day 1)) :is-cool true))
    
(let charlie (Friend
    :name "Charlie"
    :birthday (Date :year 1990 :month 1 :day 1)
    :is-cool true
))
```

### Accessing

```lisp
; I think we both agree this is bad
; Yes
(println "Howdy, " (Friend-name jordan))

; I think I prefer your suggestion over :
(println "Howdy, " (Friend.name jordan))

(println "Howdy, " (Friend:name jordan))
```

### Examples

```lisp
;;;; Using the :label and Struct.field notation

(struct Friend (
    name::String 
    is-cool::bool))
    
(let friend (Friend 
    :name "J" 
    :is-cool true))

(fun greet-friend (friend::Friend)
    (println "Hey, " (Friend.name friend) "!")
    (if (Friend.is-cool friend)
        (println "You are cool!")
        (println "You're kinda lame, but that's cool!")))

; Alternate function definition keywords
(fn greet-friend (friend::Friend)
    (println "Hey, " (Friend.name friend) "!"))

(func greet-friend (friend::Friend)
    (println "Hey, " (Friend.name friend) "!"))

(function greet-friend (friend::Friend)
    (println "Hey, " (Friend.name friend) "!"))
```