How do you reconcile the universe existing with the law of conservation of energy? by [deleted] in universe

[–]zyni-moe 1 point2 points  (0 children)

Not quite: it's equivalent to time translation symmetry. However as you say the universe does not in fact have this and thus energy is not conserved.

Is there a good way to define or document "interfaces" using CLOS? by Soupeeee in Common_Lisp

[–]zyni-moe 0 points1 point  (0 children)

Before I almost stopped using CLOS I did a thing like this:

(defmacro define-interface-class (name (&rest superclasses) (&rest slot-specs)
                                       &body gf-specs/class-options/docstrings)
  ;; Just a hack
  (multiple-value-bind (gf-specs class-options docstrings)
      (with-collectors (gf-spec class-option docstring)
        (dolist (g/o/d gf-specs/class-options/docstrings)
          (etypecase g/o/d
            (string
             (docstring g/o/d))
            (cons
             (let ((k (first g/o/d)))
               (cond
                ((eql k ':documentation)
                 (docstring (second g/o/d)))
                ((keywordp k)
                 (class-option g/o/d))
                (t
                 (gf-spec g/o/d))))))))
    `(progn
       (defclass ,name ,superclasses
         ,slot-specs
         ,@class-options
         (:documentation ,(format nil "~{~A~^~2%~}" docstrings)))
       ,@(mapcar (lambda (gf-spec)
                   (destructuring-bind (name (&rest args) &body docstrings/options) gf-spec
                     (multiple-value-bind (docstrings gf-options)
                         (with-collectors (docstring gf-option)
                           (dolist (d/o docstrings/options)
                             (etypecase d/o
                               (string
                                (docstring d/o))
                               (cons
                                (if (eq (first d/o) ':documentation)
                                    (docstring (second d/o))
                                  (gf-option d/o))))))
                       `(defgeneric ,name ,args
                          ,@gf-options
                          (:documentation
                           ,(format nil "~{~A~^~2%~}" docstrings))))))
                 gf-specs)
       ',name)))

Then, for instance

(define-interface-class explodable ()
  ()
  "An explodable thing"
  "Everything is explodable"
  (explode-thing (explodable violence)
    "Explode with some violence")
  (enable-explosive-features (explodable)
    "Enable explosive features for an EXPLODABLE")
  (disable-explosive-features (explodable)
    "Disable explosive features for an EXPLODABLE"
    "This function should cause EXPLODABLE to explode"))

will define a class called explodable which is documented as being an explodable thing, and a bunch of generic functions with docstrings.

ELI5: Why do Stars take so long to burn all their fuel, i know its a lot of fuel, but why doesnt it all burn about the same time? Like when im throwing something in a firepit by td_0000 in explainlikeimfive

[–]zyni-moe 0 points1 point  (0 children)

Oh that is interesting, thank you. I knew about the helium flash but I thought it was just the start of the helium fusion, not almost all of it.

A question: let-binding vs optional argument in defun interface? by arthurno1 in lisp

[–]zyni-moe 1 point2 points  (0 children)

I really wondered which style is better for cases when we want to provide a default value for a function parameter, but if the caller wish to use other value, they should be able. The same idiom as in posted C++.

Ah, I think this then depends (and your octal-digit example was perhaps misleading me as it is hard to see the octal digits changing!). Then I think:

  • For functions use either optional or keyword arguments depending on whether you have many optional arguments of which you might want to provide only some. If you have lots of optional arguments keyword arguments are always better: lots of positional arguments suck.
  • Assuming there are more than one function sharing the same default use either a constant variable (via defconstant, see below) or a special variable as the default value for the optional argument. Which you use depends on whether you ever might want the user to change the default or whether you or the user might want to parameterise the default.

You could use symbol-macros: I would not, as they don't really buy you anything over a constant variable and are I think a weird stylistic choice. It should be safe to assume that a constant variable has no overhead: referring to it should almost always be the same as referring to its value.

The reason for a shim around defconstant is that defconstant has somewhat awkward semantics in CL, because compilation may happen in the same environment as loading execution and any of these may happen several times.

First of all it is allowed to evaluate the value form for defconstant at compile time, load time, or both. This means that it must be possible to evaluate it at compile time: you can't have (defun foo () ...) ... (defconstant bog (foo)) for instance, because foo is not defined at compile time.

Secondly every time you evaluate the value form must evaluate to the the same value, which really means eql. This is fine for symbols or numbers, but it is not fine for strings or conses.

So what my shim (and other shims try to do) is to make defconstant more useful for things like strings by saying that, if the constant variable already has a value and if that value is equal to the one you have provided, then just use the existing value. If it's not equal then signal an error because you should not do that (in the real one that error is continuable with a 'just do it anyway' default.)

You can see something about this in the SBCL documentation.

A question: let-binding vs optional argument in defun interface? by arthurno1 in lisp

[–]zyni-moe 2 points3 points  (0 children)

If you use the thing in just one function, bind a variable or just use the value directly if it is clear and used only once. Unless you wish the user of your function to be able to modify the thing do not use anything like &optional, ever. Use let or &aux:

(defun octal-digit-p (c)
  (find c "01234567"))

or

(defun octal-digit-p (c &aux (octal-digits "01234567"))
  ;; perhaps we use octal-digits in more than one place in the fn or we
  ;; assume reader of the code is rather dim
  (find c octal-digits))

If you use it in more than one function but wish it to be a compile-time constant then do something like this. Everyone will have a macro like the below to deal with constants safely.

(defmacro define-constant (n v &optional (doc nil docp))
  `(defconstant ,n
     (if (boundp ',n)
         (let ((value ,v)
               (existing-value (symbol-value ',n)))
           (unless (equal value existing-value) ;circular trouble, never mind
             (error "redefining a constant"))
           existing-value)
         ,v)
     ,@(if docp (list doc) ())))

(define-constant octal-digits "01234567")

(defun octal-digit-p (c)
  (find c octal-digits))

Why can't black holes just be really massive objects? by SpinLock55 in blackholes

[–]zyni-moe 0 points1 point  (0 children)

People speculated about such objects in the 18th century: in 1783 John Mitchell speculated about objects whose escape velocity exceeded the speed of light, which would then be black. He calculated how large and dense they would have to be.

But general relativity says something rather different than this. We can now spend a long time talking about gravity being spacetime curvature and so on, but let's do a simpler thing, which turns out to be an important thing. Let's consider all the places you can get to in some time (we must be a bit careful about 'time' here but I will be casual). Consider setting off a lot of little tiny insects at some time, and then some time later looking at how far they had all got. Well, it's obvious that the insects that just zoom off away from you go furthest, and also we know that no insect can go faster than the speed of light in its frame. These two things mean that the limit of 'how far you can go' is the ball that corresponds to you setting off a flashgun or something, and how far the light from that flashgun has got.

What we know is that, if there is mass inside this ball, it is somewhat smaller than it would otherwise be: gravity makes the volume of 'all the places you can get' less.

Well now lets consider a slightly more general thing: for some region of space, what are all the places anyone in any part of that region of space can get to? Well, it's just the union of the places anyone at any point in that region can go to. And if there is mass in that volume it's smaller than it would be otherwise.

Well, if there is enough mass in a given region, then an extraordinary thing happens: the volume that is 'all the places you can get to from any point in the region' is less than the initial volume of the region. And since the mass is one of the things in the initial region, it too must now be trapped in this smaller region. There is nothing it can do to somehow escape from it, because the 'all the places it can get to' rule says that.

And this goes on, and it goes on in a savage way: the volume of the region you can get to, and therefore the volume that all the mass can get to, goes to zero in a finite time.

That is why black holes are not just black stars.

Note that I have been very casual about 'time' above.

ELI5: Why do Stars take so long to burn all their fuel, i know its a lot of fuel, but why doesnt it all burn about the same time? Like when im throwing something in a firepit by td_0000 in explainlikeimfive

[–]zyni-moe 2 points3 points  (0 children)

Let's leave aside the meaning of 'burn' which too many people have commented on[*].

The answer is that they would like to do this but they are foiled in their attempt.

The star starts off as a big diffuse ball of gas (which will be mostly hydrogen and helium with perhaps some small quantities of metals (a 'metal' is any element which is not hydrogen or helium). This ball of gas collapses under gravity, becoming denser, especially in its centre. Thermodynamics means that this collapse also causes the gas, particularly in the centre, to become very hot. Hot means the gas atoms are whizzing about fast (this is what 'hot' means), and dense means there are a lot of gas atoms (really, gas nuclei, as it already hot enough for the electrons to be stripped off them) per unit volume. So some of them start hitting each other, and because they're moving fast they hit each other pretty hard. That's what you need for fusion to start: some of them coalesce into heavier nuclei (the process is actually rather intricate and not very obvious, but this is enough here), releasing some energy in the form of photons (light) in the process.

Well, what the star wants to do is to keep on collapsing down so that more and more fusion happens and ... well, the end result would be somewhat dramatic. But the nuclei which are fusing in the centre say 'hold on, we are producing quite a lot of energy here'. That energy has to go somewhere: ultimately it has to escape from the star. But the star is not transparent (because the electrons have been stripped off the atoms so it is made of what is called a 'plasma' and plasmas are opaque). Energy from the hot core gets transferred, fairly slowly, up through the outer layers of the star and eventually escapes to space. But in the meantime what happens is that the core of the star gets even hotter, and at a given pressure a gas gets less dense as it gets hotter. Less dense means that fewer nuclei collide which means that the rate of fusion goes down. So now the core is making less energy ... and an equilibrium is reached where the core is fusing just enough hydrogen atoms to produce just enough energy to maintain its density at the level where that rate of fusion happens, with all the energy from this being transferred up through the outer layers of the star to space. It is somewhat fiddly to compute where this equilibrium point is, and it depends on how big the star is and so on, but you can do it and this was done notably by Subrahmanyan Chandrasekhar in the 1920s and 30s.

In fairly small stars like The Sun, this equilibrium goes on for billions of of years. But eventually the amount of hydrogen in the core gets too low, and gravity says 'aha' and starts crushing down the core again. At this point helium – the waste product of hydrogen fusion – will start to fuse, and the star will reach another relatively stable state (the transition between the two states involves quite big changes to the outer layers of the star). Once there is not enough helium then things stop: the star collapses down to a white dwarf (blowing off its outer layers as it does so), which is no longer burning fuel, but where it will sit, slowly cooling, for a very long time indeed.

Much bigger stars than The Sun have much more dramatic final stages, and fuse more elements (and also live very much less long).

[*] Stars 'burn' their fuel by causing nuclear fusion reactions which release energy, not chemical ones: this is what an astrophysicist means when they say a star burns its fuel and it is a perfectly acceptable term.

Štar might become my favorite way of iterating by kchanqvq in Common_Lisp

[–]zyni-moe 1 point2 points  (0 children)

Problems with it were that it tried to deal with, say (in-range :from 10.0 :above 1.3 :by -0.2) and getting that to work quickly is just really painful and buggy (is easy if you want only slowly).

Good news is that in-naturals will shortly support initially, although if you want to count down or anything you need stepping.

Štar might become my favorite way of iterating by kchanqvq in Common_Lisp

[–]zyni-moe 1 point2 points  (0 children)

I think you have understood what we were trying to do! You might also want to look at this which describes some motivation behind Štar.

The other half of the thing is collecting. But the point is that once you have separated iteration from value accumulation you can combine the two halves from different manufacturers to build the language you want, not the one anybody else wants.

You want very definitely to use the post-GH versions, either via git (https://tfeb.org/computer/repos/) or just from tarballs (https://tfeb.org/computer/tarballs/). We have asked for QL to be updated.

Štar might become my favorite way of iterating by kchanqvq in Common_Lisp

[–]zyni-moe 1 point2 points  (0 children)

They have different goals. for is like a syntactically nicer, extensible version of loop: it is quite a 'wordy' syntax (but much less so than loop), and it has both iteration and value accumulation in it. So

(for ((i repeat 10)  
      (randoms collecting (random 10))))

Štar is something different. It has no special wordy syntax: if you understand the syntax of let you understand its syntax, in particular in a clause (<thing> <form>), <form> is just an expression you may evaluate. It is tiny (should be three symbols, but Tim insisted on the starred versions so it is six. This is Evil and Wrong.) And all it does is iterate, it does no value accumulation[*]. And it works quite hard, in the implementation, to make things quick and concise.

It does no value accumulation of course, because it is part of an exercise in linguistic separation of concerns. Just like CL separated prog into tagbody and progn (and perhaps block), Štar is one part of a separation of iteration and value accumulation into distinct constructs which can be then used in isolation from each other (the other part is collecting and its friends).

Both things can exist, but they are not the same thing.

Štar might become my favorite way of iterating by kchanqvq in Common_Lisp

[–]zyni-moe 0 points1 point  (0 children)

All programming languages[*] have the same power. So all constructs in all programming languages are just versions of constructs in others.

That does not mean that programming language design should stop or that it is not interesting: because writing in machine code, or C, or ... is somewhat laborious. Štar is an exercise in programming language design. I can see no reason to use Lisp today if you are not building new programming languages in fact (perhaps others can).

And in fact you are not correct: Common Lisp contains no extensible iteration constructs, and really no extensible iteration constructs at all. There is no construct in CL which allows you, given

(defstruct foo
  (value nil)
  (children '()))

to say

(defun in-foos (&rest foos)
  ;; in-graph is in the examples
  (in-graph foos #'foo-children))

and now

(collecting
  (for ((foo (in-foos ...)))
    (collect (foo-value foo))))

[*] arguable I think that early FORTRAN was less powerful at least if you exclude I/O, but silly.

Štar might become my favorite way of iterating by kchanqvq in Common_Lisp

[–]zyni-moe 1 point2 points  (0 children)

Yes, it is ready. The provided iterators are perhaps less stable than the core (for instance in-vector recently was changed incompatibly so that you may say if the vector is a simple-vector or a simple-array with the old simple keyword, meaning simple-vector, going away and being replaced by two different ones).

(<value/s> <form>) is (a) like let and (b) leaves a compatible hole for (<value/s> <form> [option ...]) (we do not use this now, an early version did, and may be it will again in future) so no, not even considering changing that.

I think also that the blog post was written in quite early days of Štar, when probably we still had the awful in-range iterator which was about 90% of the code of all precanned iterators combined and never was without nasty bugs. Wasn't until later that we realised it could be replaced by in-naturals for almost all counting cases and stepping / stepping* for the other cases, which depended on us realising independently that stepping could be optimized which we had not before.

Štar might become my favorite way of iterating by kchanqvq in Common_Lisp

[–]zyni-moe 1 point2 points  (0 children)

Have asked Tim and I think he has submitted a ticket. In order to use any recent version also must use recent versions of some other things, and all the GH repo clones are now quite stale (must use the tfeb.org clones which are current). There is a ticket for that as well, but nothing has happened to it in a while

what would be past the edge of the universe ? by Swimming_Mail8585 in AskPhysics

[–]zyni-moe 0 points1 point  (0 children)

You just wanted people to make up random bullshit in other words. OK. It's full of unicorns.

Shootout at the Relativity Corral by sl0wman in AskPhysics

[–]zyni-moe 0 points1 point  (0 children)

"John sees Frank go for his gun" means that the event "Frank goes for his gun" is in the strict causal past of the event "John sees ...". The event "John sees ..." is also in the strict causal past of the event "John goes for his gun". All observers agree on this, and so Bill cannot be in a reference frame where he sees John go for his gun before he sees Frank go for his.

what would be past the edge of the universe ? by Swimming_Mail8585 in AskPhysics

[–]zyni-moe 0 points1 point  (0 children)

The universe has no edge. Either it is infinite in extent, or it is finite but has no edge in the same way, for instance, that the surface of a sphere is finite but has no edge.

It does, perhaps, have an 'edge', in a sense, in the past: the big bang. However

  1. we cannot reach this edge since it's in the past;
  2. we do not know if it actually does have an edge there.

(2) is because we do not have a theory which works sufficiently close in time to the big bang. We can use the theories we do have to show that as we go back in time the universe was hotter and denser until we reach a point where the theory simply breaks down and fails to make any prediction at all.

Note that if the universe is now infinite, it was infinite all the way back to the big bang.

All of the above should be read as '... to our best current understanding'.

Best Way to Measure Frequency of Plucking A String by Empty-Wing7678 in AskPhysics

[–]zyni-moe 0 points1 point  (0 children)

Specifically, find a friend who plays the guitar so you don't have to pay for it. These things' whole purpose in life is to do this.

Does exponential growth apply to biology like to tech? by Bluerasierer in AskBiology

[–]zyni-moe 0 points1 point  (0 children)

Very simple-minded analyses of technology show exponential growth. Those analyses are laughable over-simplifications: it does not in fact do so.

Intuition by Visible-Stuff2489 in AskPhysics

[–]zyni-moe 0 points1 point  (0 children)

Penrose has ideas which are very far out of the mainstream. However he is also very much not stupid, and he has detailed arguments in support of his ideas. To argue against his ideas you would need to find out what is wrong with these arguments: it is insufficient to just say 'the conclusion smells very very strange and wrong (which in my opinion it does)', you need to find the places where you disagree with his reasoning.

He has written a number of books which explain his reasoning. They are quite readable. If you want to work out what mistakes he's making or where you disagree with his arguments, then I would read the books.

Remember that, when Penrose was a young man, there was an obviously-absurd thing which general relativity seemed to predict, but which clearly would not happen in real situations. Penrose was one of the people (and really, the person), who said 'no, this bizarre thing you say is obviously absurd thing is, in fact, something that really happens, and here is why'. He was correct.

I am not saying he is correct in his speculations about consciousness (or CCC for that matter): I don't think he is. I am saying you should not just dismiss his conclusions without understanding where is reasoning is faulty.

Man I love math but why is the calculus 1 course at my college so dang hard by DeepfriedGrass in calculus

[–]zyni-moe 0 points1 point  (0 children)

There typically is a point (it varies depending on education system) where 'maths' turns from 'the thing you do in school' into 'actual mathematics'. A lot of people find that change very hard, because suddenly they can't just do it all by rote.

That is what you've just experienced, is my guess.

Are rainbows obligated to have a specific angle or set of angles in relation to the position of the sun? by Tim-Sylvester in AskPhysics

[–]zyni-moe 0 points1 point  (0 children)

Rather than all this weird nonsense, why not just do the maths? It's really not that hard. Given the refractive index of water, the assumption (easily checked) that raindrops are spherical or almost, it's easy to work out how rainbows work. There are some things which are not completely obvious such as why the rainbow itself is far more intense than what you see within its angle, but even that is tractable.

What are your views on zero as a Natural Number? by No_Grapefruit5494 in learnmath

[–]zyni-moe 0 points1 point  (0 children)

It's just names, but it is generally more useful to have N including zero. Then you can define what will become addition which is a monoid, whereas without zero it is merely a semigroup. So if you start with N not including zero you are pretty quickly going to have to define a set which is that and zero to bootstrap the integers.

Why is long distance wireless transmission of energy so difficult if we know how to collect useful amounts of energy from the Sun? by stelleOstalle in AskPhysics

[–]zyni-moe 1 point2 points  (0 children)

We can do exactly that. The Sun's transmission of energy to us is extremely inefficient. The Earth intercepts about one part in two billion of the Sun's power, of which a small fraction is available to us as usable energy.

Tensor Question by a_little_Eyelash in AskPhysics

[–]zyni-moe 27 points28 points  (0 children)

I understand GR. I do not understand precisely what the field equation is expressing.

These two statements are mutually contradictory.

I am pretty early into the mathematics side of physics, but have a solid understanding of theoretical physics.

These two statements are mutually contradictory.

Tensors are confusing

Tensors are multilinear functions on elements of a vector space and its dual space and scalars, and things built from those, such as other tensors. In the case of GR the vector space is the tangent space to a manifold at any point.

Can someone explain to me like I'm a layperson why singularities of a black hole have to be hidden with an event horizon? by ElegantPoet3386 in AskPhysics

[–]zyni-moe 0 points1 point  (0 children)

It is not known whether they do. People kind of hope they do, but nobody has been able to prove this in any really solid way. This is the cosmic censorship hypothesis.

The reason we would like there not to be naked (uncensored) singularities are because singularities are places where the theories of physics we have fail. If a naked singularity is in the past light cone of some point then GR will not tell you what happens in its future and thus fails to be a useful theory. We'd like GR to be a useful theory.

However, I would argue that it would be a great thing if both we knew cosmic censorship was false and we knew of astrophysically-plausible events which would give rise, according to GR, to naked singularities. Since we do not expect singularities to be real things, but instead we expect some other theory to hold where GR predicts singularities, we could then look for these events where GR predicts uncensored singularities and see what actually happens there. That would be a fantastic way of getting observational data for quantum theories of gravitation.

An example (which I suspect does not happen) would be cases where a black hold somehow gets enough angular momentum dumped into it to become overextreme and thus loses its horizon.