On 29 November 2014 at 19:19, Jeff Waller <[email protected]> wrote: > > const r_sun = 695500.0KiloMeter; export r_sun >> const r_jupiter = 69173.0KiloMeter; export r_jupiter >> const r_saturn = 57316.0KiloMeter; export r_saturn >> > > .... > > I have a semi-related question. Why this way? Why not read these values > from a database > at startup or at least a file of HDF5 or JSON. Do you find yourself > cutting-and pasting > constants all over the place? >
What is the benefit of an HDF5 or JSON file versus just having a module with the constants I want? The module is loaded in my ~/.juliarc.jl file so I have it automatically when I start the REPL. To answer your other question: No, I don't find myself copy-pasting constants a lot. This is just the first example that came to mind. I do often like to line up my code vertically because I feel that it helps me catch errors. Here are other code samples: Ax = - (1-u)*(x+u) / rho1^3 - u*(x+u-1) / rho2^3 Ay = - (1-u) * y / rho1^3 - u*y / rho2^3 Az = - (1-u) * z / rho1^3 - u*z / rho2^3 Or CJ = method == 1 ? CJ_method_1 : CJ_method_2 df = method == 1 ? df_method_1 : df_method_2 Ht = method == 1 ? Ht_method_1 : Ht_method_2 Of course, these examples are a lot less transparent than my first example. But it doesn't matter. I have always been happier with code where all the columns line up nicely. Another use of multiple cursors is to select a bit of text and pressing Ctrl+D to select additional instances of that code. Cheers, Daniel.
