/dpt/ Daily Programming Thread

What are you working on, Jow Forums?

Previous:

Attached: g_sicp_2.png (1427x1360, 1.29M)

Other urls found in this thread:

pastebin.com/LQxefE1j
twitter.com/AnonBabble

the absolute state of c++ (compiled with optimizations)

#include
#include
using namespace std;

int main(void) {
complex delta;
complex mc[4] = {0};

for(int di = 0; di < 4; di++, delta = mc[di]) {
cout

Thank you for posting an animu/mango image.

Attached: 1420229460495.png (485x354, 300K)

My pleasure.

>Writing a lisp interpreter for the application
So would the interface look something like this:
User presses some key combination (such as M-x like emacs)
Prompt user to input some lisp expression
Evaluate the expression.


This seems straightforward enough, but I'm having trouble thinking about how the lisp expression be able to mutate the internal data structure for the application.

I'm planning on having a structure like:
struct toDoItem {
int priority;
std::string item;
toDoItem* subItems;
};

struct toDoApp {
std::vector items;
}

How can I better define this to not eat stack space?
(define (replicate x n)
(if (zero? n)
'()
(cons x (replicate x (- n 1)))))

Probably because they use bolt-on web bloatworks nowadays.

Use an inner function with an iterative process. The inner function has an accumulator parameter, and tail calls itself.

You should read SICP.

>old thread reach bump limit
>anime
>SICP
based OP, thank you for posting an anime image.

yeah
but part of the reason they do that is because it's a huge pain in the ass to write things like UI without garbage collection so I dont think carmacks suggestion is a bad idea, although reference counted GC works just as well in my opinion

#include

void foo() {
// This code compiles
std::string(bar);
}

Attached: 1536917431584.png (1000x928, 128K)

What's the problem?

compile it with -O2 or -O3

IMGUI is ideal for games since you're redrawing the whole screen each frame anyways.

declarator syntax was a mistake
functional style casts were a mistake

I did
$ cat absolute.cpp
#include
#include
using namespace std;

int main(void) {
complex delta;
complex mc[4] = {0};

for(int di = 0; di < 4; di++, delta = mc[di]) {
cout

Not him, but something like this? Like, instead of building up the expression as you return from the recursive calls, build it up as you call your function recursively?

(defun replicate-iter (curr-list value n)
(cond ((= n 0) curr-list)
(t (replicate-iter (cons value curr-list) value (- n 1)))
))

(defun replicate (value n)
(replicate-iter '() value n)
)

(replicate 5 5)

Like so, then?
(define* (replicate n x #:optional (acc '()))
(if (zero? n) acc
(replicate (- n 1) x (cons x acc))))

ah, could be a gcc thing.
It's an infinite loop on gcc

Sure. I'm not familiar with optional args or define* so I'd just do this, but it seems you have the right idea.
(define (replicate n x)
(define (iter acc n)
(if (= n 0)
acc
(iter (cons x acc) (- n 1))))
(iter (list) n))

you're right, just tried it with gcc.

var render_result := render(init);
var play_result := start(silence);
loop {
match await choose(render_result, play_result) {
Left((s, b), fut) => {
let cont = await fut;
render_result := render(s);
play_result := cont(b);
},
Right(fut, cont) => {
render_result := fut;
play_result := cont(silence);
}
}
}

I am going to keep posting this until someone comments on it.

One of the primitives in the interpreter would be a closure, which you'd probably implement with two pointers, a function pointer and an argument pointer. When evaluated, it would call the function pointe on the argument pointer. If you use global state, you could get away with just one pointer.

Let's say I get the address of some WinAPI function in kernel32.dll.
If the memory of some process contains the said address, does it mean that the said process used this WinAPI function?

Attached: 1531243694604.png (700x467, 78K)

who's to say this function is not loaded at different addresses in the virtual address spaces of different processes?

whats wrong with C#

what language is this?

haskell a fun

Java + bloat
you can't fix something built on a broken foundation

Mine, in the design phase.

if you're designing a language please consider the fact that you don't need semicolons to explicitly end statements

I went from making a program that tells you "your mom gay" to working on a robot brain. I have no idea what I'm doing but the whole point is it's a learning project. I'm modeling the brain after the hemispheres of the human brain.

Semicolon insertion is worse.

What's the best way to detect when certain kernel32.dll functions (such as WriteProcessMemory) are used by some process?

We We should compromise and use , to end statements.

>Semicolon insertion
\n should just function as ; does maybe with an optional symbol to ignore a newline for multi-line statements

; doesn't end a statement. It makes a statement from an expression.

>significant whitespace
"no"

Employed Haskell programmer reporting in :)

Attached: 1463363949111.jpg (511x509, 36K)

I actually agree. If comma is used as a statement separator (instead of a terminator) and compound statements are expressions then you elegantly combine compound statements and "ordinary" parens which indicate precedence.

Alternatively, if you want tuples in your language, you can use parens for any tuples and just use braces for the combined precedence markers + compound statements. That gives you a simple syntax for unary tuples, which many languages struggle with.

>>significant whitespace
whitespace is already significant. spaces seperate tokens that are words. semicolons tell the compiler absolutely nothing that can't be inferred. \n has universally understood meaning. If you're stuck in past defending bad design decisions from 50 years ago you shouldn't be making a new language

>hasklel

I just want error checking in the editor. How can I do this on linux?

god i wish

Looks like a mix of go and rust. Do you have a compiler yet? What’s the selling point of your language?

How to intercept WinAPI calls globally? Let's say I want to intercept all calls of WriteProcessMemory from kernel32.dll.
How do I do that? I can obviously DLL inject all the system's processes as root, but is there a less retarded solution?

Attached: 1500313615396.jpg (1469x1102, 320K)

Stop spamming

Do you write Haskell for money, or do you just use Haskell at home?

people pay him to stop talking about haskell

This is the first question of this kind in this thread. Do you suffer from mental retardation?

I'm really enjoying ruby!
pastebin.com/LQxefE1j

Basically, this was originally a Python script that wasn't all that great, but found rewriting it in Ruby to be a much more pleasant experience!

{
foo();
bar();
}

should not be the same as
{
foo();
bar()
}

The former is a compound statement whereas the latter is a block expression that evaluates to the result of bar(). Without semicolons, they could not be distinguished.

I guess the syntax is like Go/Rust, although I'm not really basing the language off either of them. It's more like a sibling to Rust, coming from an ML heritage (especially Concurrent ML). No implementation yet, it's too early in the design process. I suppose the selling point is formal verification of reactive programs, including stepwise refinement.

That code is really an example of an executable specification which naively uses an extra thread to coordinate the actions of a rendering thread and a real time audio thread. It's intended to be refined further, so that there is no coordinating thread in the final program yet it behaves the same way (aside from hopefully better performance).

Ruby will never be a LISP

>The former is a compound statement whereas the latter is a block expression that evaluates to the result of bar(). Without semicolons, they could not be distinguished.
they can distinguished by inferring the context or a return statement

How do I set up a C build system with sublime on debian?

I'll just stick with semicolons, thanks.

and I'll stick with C++ if I want to use a language with shitty syntax

How will I ever recover

Where is the gnelf shell???

Use Meson.

How to monitor for new process creation via C++? Should one use WMI?

Attached: agent_smith.gif (500x200, 998K)

(defun replicate (x n)
(loop repeat n nconc `(,x)))

>loop
iterate is better

That is extremely wasteful.
You must traverse n factorial lmao.
Not to mention it uses the disgusting construct that is loop

How is it wasteful? There is no copying going on.

What if functional languages were the standard, and imperative languages were the plucky quirky oddity?

Attached: __shameimaru_aya_touhou_drawn_by_henohenomomiji__sample-6c509b80c026f79304cbd3a0c7f86e51.jpg (850x1202, 368K)

(make-list 3 :initial-element 6)

JavaScript rocks!

Attached: js-rocks.png (1000x494, 369K)

they are when you're dealing with abstract math that doesn't have real-world computation and memory requirements

Attached: c00.gif (480x270, 3.6M)

why should I use intellij instead of eclipse?

yes

yes

I know no copying, but mustn't nconc traverse the list each time fully. Mind the list grows linearly to n
Therefore, it must traverse n + (n - 1) + (n - 2) ... 0
times. Which is inefficine because it should just be n

Thank you. I now have this, which is more aptly named.
(define replicate make-list)

What programming language fits someone stuck in a tiny pink chastity cage? Ty

Is it just me, or is the bare minimum to get a programming job these days a CS degree from a top 10 school? If you're self taught you're basically fucked.

Attached: 1537418388158.png (640x480, 397K)

>Never works as a developer
>Never made a startup
>Never freelanced
>Taught himself code in his parent's basement
>Wrote 10 lines then got distracted by memes
Yes, I too am """"self taught"""" pls gib job mkay.

I want to learn rust but it looks too different from c/++/# and I have no real use for it

>FP
>dealing with abstract math
Howling like a fox rn

Attached: smug_ran8.jpg (1111x857, 571K)

I took a peek at SJWlang and I'm getting hooked. Pls halp.

>just get experience lmao
Yeah, getting a job is kind of the problem m8. I'm a mechanical engineer but software has been my hobby for quite a while.

Attached: this happens like eight times a day.gif (271x201, 1.49M)

just use c++>=11 without dynamic cast without catch without virtual inheritance

But the package manager
And the opinionated formatter
And the immutability

No. Macroexpand the loop.

literally proves me right

Attached: 2018-10-13-210229_686x249_scrot.png (686x249, 13K)

vcpkg
set up your own formatting rules
const

(BLOCK NIL
(LET ((#:LOOP-REPEAT-591 (CEILING N)))
(DECLARE (TYPE INTEGER #:LOOP-REPEAT-591))
(LET* ((#:LOOP-LIST-HEAD-592 (LIST NIL))
(#:LOOP-LIST-TAIL-593 #:LOOP-LIST-HEAD-592))
(TAGBODY
SB-LOOP::NEXT-LOOP
(IF (

why this gay code when one could instead write
(loop repeat n collect x)

Bruh it doesn't take work experience to go onto github, find a program, look at the reported bugs, then copy it to a local directory, then fix those bugs.

>(RPLACD #:LOOP-LIST-TAIL-593 (SETQ #:LOOP-LIST-TAIL-593 (LIST X)))

this line confuses me, explain it please

You could. This expands to the same code for me.

CL-USER> (let ((foo (list nil)))
(rplacd foo (setq foo (list 1))))
(NIL 1)

repeat for n

lisp a shit

I just repeat the code from the Ansi C but got the error.

#include

/* counting character in input; 1st version */

main() {

long nc;

nc = 0;
while (getchar() !=EOL)
++nc;
printf("%ld\n", nc);
}


what is wrong?

it's EOF not EOL

Sometimes, I think whether things like tagbody, or prog, should even be a thing in LISP.
They are useful, I won't deny, but still.

Eh, building blocks on building blocks. Those abstractions have to come from somewhere...

Thanks for the tips lads, really appreciate it.

I must say that I prefer TAGBODYs, GOs, PROGs and RETURNs rather than coninuations.

It's undefined behavior. Since you're incrementing di before assigning mc[di] to delta, on the last pass through the loop you're assigning from past the end of the mc array.

How do I write a program that can do a poo and a pee???