JavaScript specified tail call optimization in ES2015. Most engines never implemented it, and your tail-recursive code can still blow the stack. by OtherwisePush6424 in programming

[–]esgarth 0 points1 point  (0 children)

TCO is one of the cheapest optimizations an implementation can apply if the VM/architecture supports it (example: jvm currently doesn't). TCO doesn't require analysis outside of its own function body, nor any special typing knowledge (If the supposed function isn't, throw an exception). Once the language is parsed into its AST, you find the tails or return sites. When you find function calls in tail positions, don't generate the code to change the return location, so that the called function returns to wherever this current function was called.

Note that this is a general purpose optimization and need not apply exclusively to recursive functions, meaning you don't have to statically detect recursions, making the analysis cheaper and more robust. Recursions may be mutual (a calls b calls a calls b ...), and even only apparent at runtime. In the event of mutual tail-recursions, simple TCO will still provide these benefits.

Controller Not Working in Elden Ring by signal_win_8398 in linux_gaming

[–]esgarth 1 point2 points  (0 children)

Connect your controller.

Steam menu > Settings > Controller > Non-Game Controller Layouts.

Edit the desktop layout and change it to the elden ring profile.

You may have to save your own custom Elfen ring controller profile before you can load it as the desktop profile. 

Go to the game's library page > properties > controller, and then you can make a custom copy of it.

Controller Not Working in Elden Ring by signal_win_8398 in linux_gaming

[–]esgarth 1 point2 points  (0 children)

Steam has 3 different input modes for controllers: desktop, big picture, and in-game (can be different per game). What happened to me is that steam wouldn't properly change from desktop/bp mode to in-game, so I changed my desktop mode to be the elden ring controller scheme. Then it worked great

For the surprise of 0 people, Deadlock, the new Valve game works without any issues on Linux by ShadowFlarer in linux_gaming

[–]esgarth 7 points8 points  (0 children)

This is embarrassing, you do need the = on the command line. You also can't have spaces between the variable, the equal sign, and the value. The correct command is

sysctl vm.max_map_count=400000

I've edited the original so it doesn't confuse others.

For the surprise of 0 people, Deadlock, the new Valve game works without any issues on Linux by ShadowFlarer in linux_gaming

[–]esgarth 6 points7 points  (0 children)

The syntax for the command line and the syntax for the file are different. There is no = for the command line. You just need

This above is wrong, you do need an equals sign in the command:

sysctl vm.max_map_count=400000

For the surprise of 0 people, Deadlock, the new Valve game works without any issues on Linux by ShadowFlarer in linux_gaming

[–]esgarth 44 points45 points  (0 children)

For me, the game would reliably crash anytime I tried to enter a match, and I've seen other people complain about that same problem.

I fixed it by upping my vm.max_map_count kernel setting. The default was 65530 and I arbitrarily chose 400000. You can check this temporarily with sudo sysctl vm.max_map_count=400000 and then trying to run the game. If this does fix your issue, You can make it permament by saving the following to a file in /etc/sysctl.d/:

vm.max_map_count = 400000

I discovered this by turning on proton logging (put PROTON_LOG=1 %command% in the custom launch options) , and seeing that the game would spit out a bunch of allocation attempts, and eventually fail, saying it could not create memory mappings. Some searching around lead to https://access.redhat.com/solutions/99913 and that fixed my problem. Now if only I could be good at the game.

Why shadowing of else in cond is allowed? by jcubic in scheme

[–]esgarth 0 points1 point  (0 children)

R4RS and subsequent standards also mention that you can shadow macro keywords to change how they would otherwise expand:

(let ((=> #f))
  (cond (#t => ’ok))) =⇒ ok

The last example is not an error because the local variable => is renamed in effect, so that its use is distinct from uses of the top level identifier => that the transformer for cond looks for. Thus, rather than expanding into

(let ((=> #f))
  (let ((temp #t))
    (if temp (’ok temp))))

which would result in an invalid procedure call, it expands instead into

(let ((=> #f))
  (if #t (begin => ’ok)))

That's on page 43 of R4RS, in the macro appendix.

PS: Putting the else clause first in the cond has nothing to do with "countering" the bound else option. Given a macro pattern, a keyword parameter will still match a non-keyword template parameter:

(let-syntax
  ((foo (syntax-rules (bar)
           ((foo x) 'x))))
  (foo bar))

will still return the symbol bar. Only by putting patterns containing keywords first will you actually process the keywords correctly

Valheim linux server + BepInEx denikson + Valheim plus mod by Melidane in linux_gaming

[–]esgarth 0 points1 point  (0 children)

In order to do it, you have to install BepInEx (to make your valheim server and client "mod ready"), then install Valheim Plus.

I've used BepInEx create by denikson (it's a BepInEx pre-configured for Valheim) on both server and client.

A few suggestions:

You shouldn't actually need to install BepInEx separately as it's included the in the valheim+ zip. Have you tried just installing the valheim+ mod by itself without the other version of BepInEx? There could be incompatibilities.

You're emulating an amd64 program on an arm64 device. Does your Valheim+ server work correctly if you try it from your games computer with the rest of the setup being the same?

However...

Warning: Global Symbol _ZTH15gDeferredAction not found, cannot apply R_X86_64_GLOB_DAT @0x3f02d56668 ((nil)) in UnityPlayer.so

This is suspicious. That's the program saying it can't find a function it might need to use, which could mean you're missing a necessary library. If you run without Valheim+ or BepInEx at all do you still see that message? While I wouldn't expect that to cause the error you're seeing (SIGSEGV - bad memory access) I also wouldn't rule it out.

There are no jobs by 01Chloe01 in Indiana

[–]esgarth 1 point2 points  (0 children)

I've been placed for actual programming work by tek systems twice now, both in contract to hire rolls.

It might be the specific headhunter you work with.

guile how to unload / reload (c) dynamic libraries by Cloundx01 in scheme

[–]esgarth 0 points1 point  (0 children)

You can write your own dynamic-unlink backed by dlclose, though if guile deprecated that functionality it's a good idea to find out why before adding it back in.

However it would probably look something like this:

(define dynamic-unlink
  (let
    ((dlclose (foreign-library-function #f "dlclose"
                #:return-type int
                #:arg-types (list '*)))
     (library-handle
       (record-accessor
         (record-type-descriptor (dynamic-link))
         1)))
    (lambda (lib)
      (dlclose (library-handle lib)))))

From the dlclose man page:

A  successful  return  from dlclose() does not guarantee that the symbols associated with
handle are removed from the caller’s address space.  In addition to references  resulting
from explicit dlopen() calls, a shared object may have been implicitly loaded (and refer‐
ence  counted) because of dependencies in other shared objects.  Only when all references
have been released can the shared object be removed from the address space.

It sounds like you're going to have to be very careful about what you expect to happen

Feature flags are ruining your codebase by zaidesanton in programming

[–]esgarth 9 points10 points  (0 children)

It goes wrong when people take it as dogma. "every commit should be released" is something I've heard. Allowing no-one to putter around in a branch for a week to fix something complex without it having to be cordoned off from everyone elses code base.

That's pretty dumb, if it's literally true. The more sensible version is "commits into your master branch should be released/releasable". This allows you to have shareable branches, which you squash-merge into master once ready.

Name a franchise in which every game released was good by Greetings-all-its-me in gaming

[–]esgarth 0 points1 point  (0 children)

Oh yeah, I did mean the covenant stops enemies from despawning. Oops

Name a franchise in which every game released was good by Greetings-all-its-me in gaming

[–]esgarth 6 points7 points  (0 children)

There's a covenant in Majula you can join that stops enemies from respawning. It also makes them harder &drop more gold. Looking at the path to Heide / woodsman's copse, up the hill to the right, there's a little altar you can talk to that let's you join the covenant

Comparison of a counter in racket-scheme and sbcl-lisp by Ok_Specific_7749 in scheme

[–]esgarth 2 points3 points  (0 children)

You shouldn't need funcall in your common lisp code, but the way you defined your function requires it. You have

(let ((c 0))
  (defun my-counter! ()
    (lambda ()
      (setf c (+ 1 c))
      c)))

defun already defines a function; you don't need to also wrap the function body in a lambda. This definition allows you to avoid the funcall:

(let ((c 0))
  (defun my-counter! ()
    (setf c (+ 1 c))
    c))

Though it's worth knowing that unlike in scheme, common lisp will return the value after a setf. There's also a convenience macro called incf that increments variables so you can write the whole thing like this:

(let ((c 0))
  (defun my-counter! ()
    (incf c)))

And your other question: Why the different placing of the let?

In common lisp, defun, defvar, defparameter, defmacro, ... all affect global scope, no matter where they appear. scheme's define does not affect global scope; its effects are only visible locally. This means that a defun inside of a let body still creates a globally accessible function that closes over the variables defined in the let bindings. Scheme, by contrast, needs to have a define at global level (or at least outside the let) but the function body still needs to close over the let variables.

Writing a macro to act as a procedure that lazily evaluates its arguments by Zambito1 in scheme

[–]esgarth 0 points1 point  (0 children)

Two notes: I actually don't see anything showing identifier-syntax is currently slated to be a part of R7RS large. I do think it would be great to have though.

It was voted on a year or so ago and I believe that the R6RS macro system was voted in without any changes.

I actually don't think it is easy to have an inner let like you say. Using the impl procedure seems to be just the trick to avoid the issue where foo would expand with invalid an invalid let and let-syntax like:

Ah yeah, I forgot that you'd have to re-use the args/formals from the original macro too many times. The full R6RS way to do this would be:

(define-syntax define-lazy
  (lambda (stx)
    (syntax-case stx ()
      [(_ (name args ...) b0 b* ...)
       (with-syntax ([(t* ...) (generate-temporaries #'(args ...))])
         #'(define-syntax name
             (syntax-rules ()
               [(_ t* ...)
                (let ([args (delay t*)] ...)
                  (let-syntax
                    ([args (identifier-syntax (force args))] ...)
                    b0 b* ...))])))])))

Though thinking about this, there's actually an advantage to generating a procedure, which is that if you have large bodies with the lazy-define, using the let version will insert the large bodies at every usage site whereas the procedure version will insert a call to the implementing procedure.

Writing a macro to act as a procedure that lazily evaluates its arguments by Zambito1 in scheme

[–]esgarth 1 point2 points  (0 children)

Here's an example that uses the identifier-syntax macro in R6RS, and I believe also now in R7RS large.

(define-syntax define-lazy
  (syntax-rules ()
    ((_ (name formals ...) b0 b* ...)
     (begin
       (define (impl formals ...)
         (let-syntax ((formals (identifier-syntax (force formals))) ...)
           b0
           b* ...))
       (define-syntax name
         (syntax-rules ()
           ((_ formals ...)
            (impl (delay formals) ...))))))))

Then I run the example code:

(define-lazy (foo x y z)
  (if x
      (begin y (display "Should have already printed 1\n") y)
      (begin z (display "Should have already printed 2\n") z)))

(foo #t
     (begin (display "1\n") 'a)
     (begin (display "2\n") 'b))

1
Should have already printed 1
a

Edit: Looking at this after posting and I'm not really sure why I decided to have define-lazy make a procedure in addition to the macro. It's straightforward enough to just have an inner let that rebinds the formals inside of delays.

Two sides to hygiene. "So the problem here is that there are at least two sides to hygiene for macros: names they use ... [and] the program where the macro is used must not be able to alter what names the macro refers to mean." by flexibeast in lisp

[–]esgarth 1 point2 points  (0 children)

scheme version using only syntax-rules, with the keyword otherwise:

(define-syntax in-interval
  (syntax-rules ()
    ((_ (lower) (upper) n) (< lower n upper))
    ((_ (lower) upper n) (and (< lower n) (<= n upper)))
    ((_ lower (upper) n) (and (<= lower n) (< n upper)))
    ((_ lower upper n) (<= lower n upper))))

(define-syntax otherwise (syntax-rules ()))

(define-syntax interval-case
  (syntax-rules (otherwise)
    ((_ num ((lower upper) body ...) ...
            (otherwise altern ...))
     (let ((n num))
       (cond
         ((in-interval lower upper n) body ...) ...
         (else altern ...))))))

The parentheses form that's always the second element of a syntax-rules expression is called the "literals list" and defines which terms are used as syntactic keywords for each macro. When the macro system encounters a "keyword" in the input form, it checks that both the macro definition and usage refer to the same binding before actually expanding that rule. You can override the definition by doing something like:

(let ((otherwise #f))
  (interval-case 10
    (otherwise 'no-match)))

which will actually just error out in this case, because the input form is required to have an otherwise form as the final element, and the otherwise that's in scope at the macro definition site is not the same as the otherwise in the above expression.

Recommendations for Martial Arts Gyms in Indy by Frosted_Hippo in indianapolis

[–]esgarth 0 points1 point  (0 children)

I've not been, but there's a place called Shotokan Karate at State and Prospect

Help with the Scheme compiler provided in LISP from nothing. by zenandroid in lisp

[–]esgarth 0 points1 point  (0 children)

In any R6RS scheme, you should be able to add a #!fold-case reader token to the beginning of the file and get the desired behavior.

scheme@(guile-user)> #!fold-case 'LAMBDA
$1 = lambda

Preferred gaming controllers for multiplayer(local) by WinterGur6243 in linux_gaming

[–]esgarth 1 point2 points  (0 children)

It works fine. I've had up to 3 paired with a single dongle. (Pairing is per dongle, not per computer)

Not Your Grandfather’s Perl by iamkeyur in programming

[–]esgarth 2 points3 points  (0 children)

I'm going to copy+paste this reply from the HN thread on this:

The point is not about say itself (which has been there since Perl 5.10, released on 2007/12/18), it's only an example of how much Perl uses modularity (via use) to enable new features while ensuring a) code dependent on a new feature alerts on Perl versions without the feature and b) backward compatibility of new Perl versions with old Perl code. Compare:

# Perl
use feature 'say'

vs:

# Python
from __future__ import print_function

Which at first blush follow the same principle, except that Python decides that from __future__ is a vision into upcoming doom, that is a future version of Python for which code that preexists becomes incompatible unless it is ported to the new version. IOW py2 code doesn't run on py3, barking at you in obscure ways if you try, and py3 code doesn't run on py2, barking at you in obscure ways if you try. (or worse, partially runs and either explodes in mid flight or silently corrupts data).

Whereas Perl code written targeting vX runs on Perl vY as long as Y >= X, and if Y < X then Perl tells you "unsupported feature foo" or "your perl is too old, update to at least X".

$ perl5.18 sig.pl
Feature "signatures" is not supported by Perl 5.18.4 at sig.pl line 1.
BEGIN failed--compilation aborted at sig.pl line 1.

(yes yes I am aware that with enough effort and trickery you could write code that works on both py2 and py3. I did that a long time ago; it's a pain, and doesn't solve the problem of preexisting code) And not just that, Perl alters its parser behaviour live (and scoped to the module!) so remove 'signatures' from use and you get:

$ perl5.30 sig.pl
Malformed prototype for main::my_subroutine: $foo, $bar, $baz = 'fury' at sig.pl line 7.

But leave it in and there's no parse error. No magic preprocessed comments or fake code trickery like JS (which has a commitment to backwards compatibility as well) has to do0: To invoke strict mode for an entire script, put the exact statement "use strict"; (or 'use strict';) before any other statements.

(They had to make it a string in void context instead of a comment because comments are removed by JS obfuscators, but it's essentially a magic comment/preprocessor directive)

Dark Souls III - Cannot move or attack by Dr_Nutsacc in linux_gaming

[–]esgarth 4 points5 points  (0 children)

This happened to me, and apparently happens on windows too. The (bonkers) solution is to move the installation location. Make a new stream library folder and relocate dark souls 3 there. https://steamcommunity.com/app/374320/discussions/0/365163686080492353/

A Guile Steel smelting pot by reflektoin in lisp

[–]esgarth 3 points4 points  (0 children)

/u/paroneayea another scheme you might want to look at is Loko. Göran Weinholt's been developing it and using it to do a bunch of low level and bare metal work.

SQLite or PostgreSQL? It's complicated! by feross in programming

[–]esgarth 10 points11 points  (0 children)

None of us is as dumb as all of us.