Fork me on GitHub
#beginners
<
2015-07-07
>
sooheon04:07:35

Don’t think in paredit, but in emacs you can use align-repeat-left-paren

sooheon04:07:27

@roberto: highlight from just before (a-fn) to past (b- and call align-repeat-left-paren will give you that state

escherize04:07:39

@roberto, are you on emacs?

escherize04:07:09

you can use align-cljlet

escherize04:07:20

you may have to install it though.

escherize04:07:22

it is on [m]elpa

iae13:07:25

Does anybody have any experience using Cursive with IntelliJ?

iae13:07:10

Well, right now I'm still too dumb for emacs beyond the basic editor commands, so that's what I'm using until I gain some proficiency.

iae13:07:17

And it works, you know? I start a leiningen repl and repl away

iae13:07:38

It would always start in my main class, the cmaze.core

iae13:07:38

And, for ease of use, I imported my other files into it

iae13:07:12

But now if I edit my cmaze.png/draw method, paste it into the repl to update it, then boom

iae13:07:17

It says the method is already defined

teslanick13:07:56

I think you want to be using the :require form in an ns declaration.

teslanick13:07:36

e.g.

(ns cmaze.core
  (:require [cmaze.util :as util :refer [ foo bar ]]))

teslanick13:07:16

But Cursive is a bit fiddly when setting up the REPL.

teslanick13:07:13

If you have that set up, though, you can reload a namespace with: (require '[cmaze.util :as util] :reload)

iae13:07:37

Do I have to do that with every repl or is that a shortcoming of the intellij environment?

teslanick13:07:51

Do what in every environment? The require/reload?

teslanick13:07:35

Yes. You need to tell the REPL when something has changed (unless you have a harness that can manage that transparently)

iae13:07:14

Hm, I wonder if there's a send to repl command like in F#

iae13:07:18

I guess that would make it a lot easier

teslanick13:07:34

Cursive has a GUI command to load a file in the REPL, I think.

iae13:07:56

Is that how you do it?

teslanick13:07:05

Tools -> REPL -> Sync Files in REPL

teslanick13:07:27

There's probably a way to shortcut that, but I have no idea how

iae13:07:56

If it's available in the keymap section it should be possible

iae13:07:44

Yup, they're all available for bindings, coolio

iae13:07:50

That should ease the pain, thanks a lot simple_smile

iae18:07:02

I think I hit a typical beginner's problem. I think I am using too many variables in my let forms, but I see no simple way to break it up

iae18:07:07

What are some good refactoring methods for Clojure?

iae18:07:35

I'm having a difficult time using OOP refactorings like extract-method or parameter-group in this context

iae18:07:39

I've verified that the code works and does as it should, I just want to clean it up to conform to clean coding standards

donaldball18:07:31

A general principle is that fns should do only one thing, and should try to be pure.

donaldball18:07:21

This draw fn does all the things and is hard to test interactively or reuse in other contexts.

donaldball18:07:17

You might consider splitting into into a pure fn that generates a data structure describing the line segments that comprise the maze, and an impure fn that writes an image file given such a data structure.

iae18:07:59

Well, draw is a purely side-effect method

iae19:07:05

The maze is generated pure

iae19:07:07

And then I want to draw it

iae19:07:12

And the java api isn't stateless

donaldball19:07:53

Fair point, sorry, I read this hastily

donaldball19:07:31

You could split it apart into a pure fn which renders a maze as a seq of lines, then an impure fn to .draw them to the graphics image, but I dunno if there's significant benefit to be gained thereby

iae19:07:35

Yes, I was thinking about your data structure advice; perhaps an intermediate vector which contains (x,y),(x',y') coordinates

iae19:07:46

Then all I'd have to do is loop over it and draw without any complexities

iae19:07:37

Oh yeah, it worked nicely! Thanks @donaldball

iae19:07:02

Although I feel that I'm still using fairly primitive tools to code and clean up clojure with

donaldball19:07:39

If you do the emacs thing, some folk enjoy clj-refactor

donaldball19:07:16

I think cursive has similar factoring tools

iae20:07:25

I do want to try emacs, I've gone for the emacs-live package and it's quite good so far

iae20:07:32

It's mostly about learning the most basic keystrokes now

iae20:07:20

I think I phrased my sentiment poorly, I meant that my use of the clojure language is still too crude. I'm only using the basic functions and I feel that i'm missing out on much cleaner, more efficient workflows