[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

New programming feature

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 13
Thread images: 2

I have a new idea of feature for a programming language, something I would call "variable expression".

Imagine that you have

Speed = deltatime * 5

It is necessary to update "speed" at each time because the value of deltatime changes.

Imagine a programming language that allows you to create a variable using an expression, but that changes each time the variables using to compute the expression change.

So, if deltatime changes, then speed changes automatically (no need to update!).
>>
this already exists, it is called reactive programming.
>>
this already exists my friendo
>>
>>61668167
>>61668169
>born too late to have a truly original idea
Life is suffering.
>>
>>61668198
Did you really think no one else had thought of this?
>>
>>61668129
nigga that's a function
>>
>>61668198
don't feel bad anon, that idea is just about 60 years old.

Still there are a lot of open problems and things to do in programming language theory, if that makes you feel better.
>>
>>61668129
>speed = time * x
t. brainlet.
>>
>>61668129
;; in Common Lisp

(defun speed ()
(* deletatime 5))
;; but really it should be:

(defun speed (deltatime)
(* deletatime 5))

;; example:

(defun update-position ()
(setq position (+ position (speed) )))

>>
File: 1491104903844.jpg (183KB, 1392x1016px) Image search: [Google]
1491104903844.jpg
183KB, 1392x1016px
Jesus christ, this is bait. He posted a picture of a lambda, whew.
In case it isn't or there are other anons who want to learn. Here is how you would do this in JS, with a lambda expression.
var speed = () => deltatime * 5;
>>
>>61669537
cont.
Also, it is not a good idea to do this it gets messy. It would be better to do something like
var speed = deltatime => deltatime * 5;

So that it at least follows functional programming.
It gets messy because speed depends on deltatime, well what if deltatime depends on two other variables which each have a messy web to follow when tracing code.
>>
>>61669537
>>61669589
At least call it getSpeed(), you barbarians
JS getters and C# properties are more closely what op described though than functions
>>
>>61668129

You mean a function?

float speed(){
return deltatime * 5.0f;
}


Place it wherever you would use Speed()
Thread posts: 13
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.