• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 04:38
CET 10:38
KST 18:38
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
HomeStory Cup 28 - Info & Preview10Rongyi Cup S3 - Preview & Info3herO wins SC2 All-Star Invitational14SC2 All-Star Invitational: Tournament Preview5RSL Revival - 2025 Season Finals Preview8
Community News
Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win3Weekly Cups (Jan 12-18): herO, MaxPax, Solar win0BSL Season 2025 - Full Overview and Conclusion8Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets4$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)38
StarCraft 2
General
HomeStory Cup 28 - Info & Preview StarCraft 2 Not at the Esports World Cup 2026 Weekly Cups (Jan 19-25): Bunny, Trigger, MaxPax win Oliveira Would Have Returned If EWC Continued herO wins SC2 All-Star Invitational
Tourneys
HomeStory Cup 28 KSL Week 85 $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) OSC Season 13 World Championship $70 Prize Pool Ladder Legends Academy Weekly Open!
Strategy
Simple Questions Simple Answers
Custom Maps
[A] Starcraft Sound Mod
External Content
Mutation # 510 Safety Violation Mutation # 509 Doomsday Report Mutation # 508 Violent Night Mutation # 507 Well Trained
Brood War
General
Bleak Future After Failed ProGaming Career [ASL21] Potential Map Candidates BW General Discussion Potential ASL qualifier breakthroughs? BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues Small VOD Thread 2.0 Azhi's Colosseum - Season 2 [BSL21] Non-Korean Championship - Starts Jan 10
Strategy
Zealot bombing is no longer popular? Simple Questions, Simple Answers Current Meta Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread Battle Aces/David Kim RTS Megathread Path of Exile Mobile Legends: Bang Bang Beyond All Reason
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Canadian Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine
Fan Clubs
The herO Fan Club! The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
How Esports Advertising Shap…
TrAiDoS
My 2025 Magic: The Gathering…
DARKING
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1513 users

The Big Programming Thread - Page 882

Forum Index > General Forum
Post a Reply
Prev 1 880 881 882 883 884 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Artesimo
Profile Joined February 2015
Germany567 Posts
May 16 2017 20:37 GMT
#17621
On May 17 2017 04:58 supereddie wrote:
Also, maybe you don't need a database at all and just use Excel's data tables? Just put the 'source data' on a seperate sheet
.
Also also, you can enable 'Filter' on rows and columns (just select the rows/columns in Excel and press Filter): possible filter values will be available in a dropdown.


Yeah, after checking out "ribbontab" (never heard that term before, thought it was something special lol), I dulged in a lot of helpful stuff that most likely covers all my needs. Feel a bit stupid now, I just googled waaaaaay to complicated. I might ditch the database since they already distribute their by hand sorted tables per dropbox.
Manit0u
Profile Blog Joined August 2004
Poland17644 Posts
Last Edited: 2017-05-16 20:42:32
May 16 2017 20:40 GMT
#17622
On May 17 2017 05:22 tofucake wrote:
I've never even heard of them. What language are they for?


They're for Elixir

Overall, this looks like slightly worse Rails. If you want simple and performant, you could always go with something like Kemal which is built on top of Crystal. Something I've been wanting to get into lately. We've recently created a simple script in Crystal to populate our database for performance testing and it did it so good that it killed our server (weren't expecting it to be this good).
Time is precious. Waste it wisely.
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-05-17 06:35:30
May 17 2017 04:48 GMT
#17623
On May 16 2017 16:17 Manit0u wrote:
Show nested quote +
On May 16 2017 08:54 Nesserev wrote:
First of all, format the code in a way so that an actual human can parse it.

That said... is this a real copy/paste code example?

The code makes no sense, uses no proper function prototyping, setjmp and longjmp clearly work very differently and are improperly used, wtf is this?
setjmp (v) int v; { ... }

Is this some archaic C dialect, what's going on?


It's C89/90:
https://software.intel.com/en-us/articles/old-style-c-function-argument-declarations-are-supported

Also, the code is formatted really bad even in the PDF. I guess someone has been teaching C for a long time and never bothered to actually track changes to the language or educate themselves past the initial point... Doesn't bode well.

Edit:

Here's the code brought up to a bit more modern standards (but it still doesn't make much sense):
+ Show Spoiler +


#include <stdio.h>

int setjmp(int v);
int longjmp(int v);
int fun1(void);
int fun2(void);

int main(void)
{
int r = setjmp(r);

if (r != 0)
{
printf("error\n");

return 2;
}

fun1();

return 0;
}

int setjmp(int v)
{
/*
...
*/
return 0;
}

int longjmp(int v)
{
/*
...
*/
return 1;
}

int fun1(void)
{
printf("start fun1\n");

fun2();

return 0;
}

int fun2(void)
{
int d;

printf("start fun2\n");

longjmp(d);

return 0;
}

+ Show Spoiler +


#include <stdio.h>

int setjmp(int v);
int longjmp(int v);
int fun1(void);
int fun2(void);
int *add; //using global, not sure if best idea
int main(void)
{
int r = setjmp(r);
if(r!=0)
{
printf("error\n");
return 2;
}

fun1();
return 0;
}
int setjmp(int v)
{
add = &v; //used a global variable
return 0;
}
int longjmp(int v)
{
int *p; //pointer
p = &v; //save argument address
*(p-1) = *add; //return address = address in main
return 1;
}
int fun1(void)
{
printf("hi1");//testing
fun2();
printf("hi2");//testing
return 0;
}
int fun2(void)
{
int a;
longjmp(a);
return 0;
}//output SHOULD be "hi1"
//output is currently "hi1" "hi2"


Here's my latest attempt at it. I added comments to all lines I added and slightly modified so I can test easier while coding.

Honestly not sure if this is the right approach but as I understand it the call stack has the arguments of the function right above the return address so by changing *(p-1) I am changing the return address in the stack?

I'm pretty lost. Prof kind of alluded to doing something with the stack and said we just need to make it output "hi1" only and he doesn't care too much how we code it as long as we're not using builtins/assembly/some other 'clearly disingenuous way'. Anyone got something for me? D: My TA's basically told me they have no idea how to do this and would have to look over it during this week to figure it out lol.

Also please let me know if my use of pointers are bad, I'm very new to C and haven't touched C/C++ pointers since my intro class.

edit:

I have another idea but I'll try again in the morning. I'll update if I finish some code up before work.
TL/SKT
Manit0u
Profile Blog Joined August 2004
Poland17644 Posts
May 17 2017 08:11 GMT
#17624

Showing 90 changed files with 98 additions and 517 deletions


I like to commit removal of 65 files from our migrations. Panic is slowly spreading
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
May 17 2017 10:14 GMT
#17625
On May 17 2017 05:40 Manit0u wrote:
Show nested quote +
On May 17 2017 05:22 tofucake wrote:
I've never even heard of them. What language are they for?


They're for Elixir

Overall, this looks like slightly worse Rails. If you want simple and performant, you could always go with something like Kemal which is built on top of Crystal. Something I've been wanting to get into lately. We've recently created a simple script in Crystal to populate our database for performance testing and it did it so good that it killed our server (weren't expecting it to be this good).

Fuck performance, I want my shit to work at all times. Erlang VM (the shit that Elixir runs on) is so fucking stable that people say bad things about you when you program defensively. It might have its shortcomings, but stability is not one of them. Neither is performance.
"windows bash is a steaming heap of shit" tofucake
Acrofales
Profile Joined August 2010
Spain18206 Posts
Last Edited: 2017-05-17 10:20:02
May 17 2017 10:18 GMT
#17626
On May 17 2017 05:37 Artesimo wrote:
Show nested quote +
On May 17 2017 04:58 supereddie wrote:
Also, maybe you don't need a database at all and just use Excel's data tables? Just put the 'source data' on a seperate sheet
.
Also also, you can enable 'Filter' on rows and columns (just select the rows/columns in Excel and press Filter): possible filter values will be available in a dropdown.


Yeah, after checking out "ribbontab" (never heard that term before, thought it was something special lol), I dulged in a lot of helpful stuff that most likely covers all my needs. Feel a bit stupid now, I just googled waaaaaay to complicated. I might ditch the database since they already distribute their by hand sorted tables per dropbox.




Seriously, wtf.

E: I mean, sure, there's plenty of perfectly reasonable things you can do this for. But this is a production database of important stuff we're talking about right?
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2017-05-17 11:29:15
May 17 2017 11:28 GMT
#17627
--- Nuked ---
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-05-17 13:24:34
May 17 2017 13:07 GMT
#17628
I think it's likely we don't understand what the professor wants, because dyslexic is missing something or the professor hasn't communicated it properly.


in other news, my last final(discrete structures) i got an 86. I don't know what the curve was yet.

So I passed all my classes. On to the 300 level! 351 (notoriously hard class) this summer. I am sure I will be VERY active here, and some of you will probably have a lot of fun with the questions.
Manit0u
Profile Blog Joined August 2004
Poland17644 Posts
May 17 2017 14:03 GMT
#17629
On May 17 2017 20:28 Nesserev wrote:
Show nested quote +
On May 17 2017 13:48 dsyxelic wrote:
On May 16 2017 16:17 Manit0u wrote:
On May 16 2017 08:54 Nesserev wrote:
First of all, format the code in a way so that an actual human can parse it.

That said... is this a real copy/paste code example?

The code makes no sense, uses no proper function prototyping, setjmp and longjmp clearly work very differently and are improperly used, wtf is this?
setjmp (v) int v; { ... }

Is this some archaic C dialect, what's going on?


It's C89/90:
https://software.intel.com/en-us/articles/old-style-c-function-argument-declarations-are-supported

Also, the code is formatted really bad even in the PDF. I guess someone has been teaching C for a long time and never bothered to actually track changes to the language or educate themselves past the initial point... Doesn't bode well.

Edit:

Here's the code brought up to a bit more modern standards (but it still doesn't make much sense):
+ Show Spoiler +


#include <stdio.h>

int setjmp(int v);
int longjmp(int v);
int fun1(void);
int fun2(void);

int main(void)
{
int r = setjmp(r);

if (r != 0)
{
printf("error\n");

return 2;
}

fun1();

return 0;
}

int setjmp(int v)
{
/*
...
*/
return 0;
}

int longjmp(int v)
{
/*
...
*/
return 1;
}

int fun1(void)
{
printf("start fun1\n");

fun2();

return 0;
}

int fun2(void)
{
int d;

printf("start fun2\n");

longjmp(d);

return 0;
}

+ Show Spoiler +


#include <stdio.h>

int setjmp(int v);
int longjmp(int v);
int fun1(void);
int fun2(void);
int *add; //using global, not sure if best idea
int main(void)
{
int r = setjmp(r);
if(r!=0)
{
printf("error\n");
return 2;
}

fun1();
return 0;
}
int setjmp(int v)
{
add = &v; //used a global variable
return 0;
}
int longjmp(int v)
{
int *p; //pointer
p = &v; //save argument address
*(p-1) = *add; //return address = address in main
return 1;
}
int fun1(void)
{
printf("hi1");//testing
fun2();
printf("hi2");//testing
return 0;
}
int fun2(void)
{
int a;
longjmp(a);
return 0;
}//output SHOULD be "hi1"
//output is currently "hi1" "hi2"


Here's my latest attempt at it. I added comments to all lines I added and slightly modified so I can test easier while coding.

Honestly not sure if this is the right approach but as I understand it the call stack has the arguments of the function right above the return address so by changing *(p-1) I am changing the return address in the stack?

I'm pretty lost. Prof kind of alluded to doing something with the stack and said we just need to make it output "hi1" only and he doesn't care too much how we code it as long as we're not using builtins/assembly/some other 'clearly disingenuous way'. Anyone got something for me? D: My TA's basically told me they have no idea how to do this and would have to look over it during this week to figure it out lol.

Also please let me know if my use of pointers are bad, I'm very new to C and haven't touched C/C++ pointers since my intro class.

edit:

I have another idea but I'll try again in the morning. I'll update if I finish some code up before work.


So, setjmp and longjmp's goal is to basically unwind the stack instantly to a certain prior state (when setjmp is called; stack frame of calling function still has to be on the stack when calling longjmp). Normally, this is done by saving the content of all registers to a buffer, and then using longjmp later to overwrite all current register values.

Problem is, you can't access the register values without assembly... so yeah, throw the idea of implementing the actual behaviour of setjmp and longjmp out of the boat, cause that's not gonna happen.

(An added problem is that, because during the execution of a function not all variables are necessarily stored within registers, and variables can be changed or pushed/popped from the stack during function execution, it becomes clear that setjmp and longjmp can lead to some nasty shit.

However, this probably won't be a problem with such simple functions, so let's ignore that.)

--

So, let's go back to the ultimate goal of using setjmp/longjmp, which is stack unwinding. Can you unwind the stack without directly accessing any registers?

Well, you could try manipulating registers by manipulating the return addresses on the stack, but then you end up again in "implementation land" with call conventions, compiler implementations, etc. which is probably way worse than the relatively clean "default" solution of setjmp and longjmp.

So, uh... I think this is a lost battle.

I'd be glad if anyone could correct me :/


Here's a nice article about it: http://blog.reverberate.org/2013/05/deep-wizardry-stack-unwinding.html

I'm not a C dev myself (just an occasional dabbler) so I can't help much in this case.
Time is precious. Waste it wisely.
dsyxelic
Profile Joined May 2010
United States1417 Posts
May 17 2017 14:13 GMT
#17630
I asked on stackoverflow and got similar responses (cant be done or awful assignment forcing bad workarounds which defeats purpose of assignment). I gave pretty much all the directions I was given...

Dunno if this helps but this was what the professor showed and talked about using the stack. He said he basically gave us the answer to the project with this:
+ Show Spoiler +

[image loading]

[image loading]

TL/SKT
Manit0u
Profile Blog Joined August 2004
Poland17644 Posts
Last Edited: 2017-05-17 20:40:28
May 17 2017 14:28 GMT
#17631
Wait a second. Your professor is giving you examples of code written in style that was used 30 years ago, that is compiled for embedded system/router architecture which was introduced 32 years ago?

This is madness...
Time is precious. Waste it wisely.
dsyxelic
Profile Joined May 2010
United States1417 Posts
Last Edited: 2017-05-17 14:40:23
May 17 2017 14:38 GMT
#17632
On May 17 2017 23:28 Manit0u wrote:
Wait a second. Your professor is giving you examples of code written in style that was used 30 years ago, that is compiled for embedded system/router architecture which introduced 32 years ago?

This is madness...


Yeah idk this is easily the worst cs class ive taken. My data structures class was in pascal as well but wasnt as bad since we were allowed to choose from python or c/c++ for any submissions. This prof is ridiculously lazy. Used same slides for years (not even made by him and is out of date) and the random midterm uploaded online by a student 5 years ago was pretty much identical to the midterm we just took.
TL/SKT
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-05-17 14:50:50
May 17 2017 14:41 GMT
#17633
trying to understand this is like the world's hardest puzzle
Acrofales
Profile Joined August 2010
Spain18206 Posts
May 17 2017 14:41 GMT
#17634
On May 17 2017 23:13 dsyxelic wrote:
I asked on stackoverflow and got similar responses (cant be done or awful assignment forcing bad workarounds which defeats purpose of assignment). I gave pretty much all the directions I was given...

Dunno if this helps but this was what the professor showed and talked about using the stack. He said he basically gave us the answer to the project with this:
+ Show Spoiler +

[image loading]

[image loading]



Image links are broken.
Hanh
Profile Joined June 2016
146 Posts
Last Edited: 2017-05-17 14:58:50
May 17 2017 14:58 GMT
#17635
On May 17 2017 23:38 dsyxelic wrote:
Show nested quote +
On May 17 2017 23:28 Manit0u wrote:
Wait a second. Your professor is giving you examples of code written in style that was used 30 years ago, that is compiled for embedded system/router architecture which introduced 32 years ago?

This is madness...


Yeah idk this is easily the worst cs class ive taken. My data structures class was in pascal as well but wasnt as bad since we were allowed to choose from python or c/c++ for any submissions. This prof is ridiculously lazy. Used same slides for years (not even made by him and is out of date) and the random midterm uploaded online by a student 5 years ago was pretty much identical to the midterm we just took.


This is highly suspicious. Clearly you can change the return address by writing in the stack but the main problem is restoring the SP. The slide does not show the epilogue of the function, just before the j $31.Though if you use this web site https://godbolt.org/ you can see that it would have


addiu $sp,$sp,40


And there is no way (that I know) to do this without assembly.

Anyway, I would give up and ask him when he returns the assignment.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
May 17 2017 15:19 GMT
#17636
If i wanted to study multivariable calculus on my own, for purposes of machine learning, can anyone set me on a track of what I could study for that?

Like, to avoid an entire course worth of work, a way to study only the topics that are relevant to ML ?
dsyxelic
Profile Joined May 2010
United States1417 Posts
May 17 2017 15:25 GMT
#17637
@acrofales
Sorry I was unable to get it fixed but the direct links work. Not sure if a tl issue or that sites issue. Id make another but away from pc atm.

@hanh
Thats what Ive been hearing too.
The weird thing is we were given 3weeks for this assignment which implies that its difficult, but the prof basically straight up said he did the assignment for us with the above example so that would mean it should be easy...

I still have 2 weeks on this so Ill prob bother the prof more till he tells me to f off. Going to my friend after work today who used to ta for this guy since my current ta's seem just as lost. If he cant get it it probably means giving up or just ignoring his stipulations.
TL/SKT
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
May 17 2017 15:29 GMT
#17638
If the professor is a scumbag, I would consider going to a professor who is not a scumbag who has also taught C at the college, approaching him in a very courteous and professional way and ask him to try to help make sense of it.

If even another prof can't make sense of it then you have grounds to challenge it if it hurts your grade.
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
May 17 2017 16:00 GMT
#17639
On May 17 2017 23:41 Acrofales wrote:
Show nested quote +
On May 17 2017 23:13 dsyxelic wrote:
I asked on stackoverflow and got similar responses (cant be done or awful assignment forcing bad workarounds which defeats purpose of assignment). I gave pretty much all the directions I was given...

Dunno if this helps but this was what the professor showed and talked about using the stack. He said he basically gave us the answer to the project with this:
+ Show Spoiler +

[image loading]

[image loading]



Image links are broken.


+ Show Spoiler [Fixed links] +

[image loading]
[image loading]
I'll always be your shadow and veil your eyes from states of ain soph aur.
emperorchampion
Profile Blog Joined December 2008
Canada9496 Posts
May 17 2017 18:57 GMT
#17640
Rofl
TRUEESPORTS || your days as a respected member of team liquid are over
Prev 1 880 881 882 883 884 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 2h 22m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
SortOf 264
BRAT_OK 122
StarCraft: Brood War
Bisu 795
Larva 417
Jaedong 402
PianO 346
actioN 233
Hyuk 224
ZerO 180
Dewaltoss 81
ToSsGirL 61
ZergMaN 49
[ Show more ]
Shuttle 47
Backho 37
EffOrt 35
NaDa 27
HiyA 25
zelot 22
Noble 21
Bale 11
Terrorterran 10
soO 8
Dota 2
XaKoH 566
NeuroSwarm116
League of Legends
JimRising 549
Other Games
gofns11676
WinterStarcraft613
ceh9391
C9.Mang0310
crisheroes178
ZerO(Twitch)9
Organizations
Other Games
gamesdonequick821
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• LUISG 10
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota247
League of Legends
• Jankos1899
• Stunt455
Upcoming Events
HomeStory Cup
2h 22m
Replay Cast
14h 22m
HomeStory Cup
1d 3h
Replay Cast
1d 14h
Replay Cast
2 days
Wardi Open
3 days
WardiTV Invitational
4 days
The PondCast
5 days
WardiTV Invitational
5 days
Liquipedia Results

Completed

Escore Tournament S1: W6
OSC Championship Season 13
Underdog Cup #3

Ongoing

CSL 2025 WINTER (S19)
KCM Race Survival 2026 Season 1
Acropolis #4 - TS4
Rongyi Cup S3
HSC XXVIII
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8

Upcoming

Escore Tournament S1: W7
Escore Tournament S1: W8
Acropolis #4
IPSL Spring 2026
uThermal 2v2 2026 Main Event
Bellum Gens Elite Stara Zagora 2026
LiuLi Cup: 2025 Grand Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.